I want to create a completedDatetime that follows the datetime in the orderDatetime field.
Fixtures.yml
directive_{200..500}:
orderDatetime: <dateTimeThisYear()>
completedDatetime: '90%? <dateTimeBetween("orderDatetime", "now")>'
I used the code above in my fixtures file and got the data that follows.
Is there a way to ensure a sane result using faker data short of writing custom functions in LoadFixtures??
Since you are passing string "orderDatetime" to
strtotime()
function it returns 1970 year and yourdateTimeBetween
works likedateTimeBetween('1970', 'now')
. Passing of variables is done with$orderDatetime
. But if you pass such variable todateTimeBetween()
, the future dateTime might get passed which is not possible.It only works if your order date is the past from now:
If you wonna generate future dates then you need to create custom faker function for example:
and use it like this: