Issue
'from' => $this->faker->dateTime($max = 'now', $timezone = null),
'to' => $this->faker->dateTime($max = 'now', $timezone = null),
In my factory file, I use method dateTime for "from" and "to", but it create with format : yyyy-mm-dd. How can I create value for "from" with format dd-mm-yyyy minute hour second ?
Solution
I understand that Carbon is included natively in Laravel, however, if you wanted a native PHP solution, since the Faker dateTime function returns a DateTime object, you can use the format()
function of the DateTime class, the documentation for which can be found here
The code for that might look like this:
'from' => $this->faker->dateTime()->format('d-m-Y H:i:s'),
Answered By - Jack465
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.