I am trying to achieve the functionality illustrated below:
$table->dateTime('time')->default(new \DateTime());
This exact code is failing, because
[ErrorException]
Object of class DateTime could not be converted to string
The other problem is, that I feel that there should be more robust/elegant way of solving this issue. So, how to correctly set a default DateTime
value in migrations?
Try this:
$table->timestamp('time')->useCurrent = true;
See, if that helps.