How to get a future date in Faker

How to get future dates using:

https://github.com/fzaninotto/Faker#fakerproviderdatetime

dateTime($max = 'now') 

i.e. what should be the value of $ max for datetime in the future

+6
source share
3 answers

Try passing the unix timestamp for $max .

 $unixTimestap = '1461067200'; // = 2016-04-19T12:00:00+00:00 in ISO 8601 echo $faker->dateTime($unixTimestamp); echo $faker->date('Ym-d', $unixTimestamp); // for all rows $faker->dateTimeBetween('now', $unixTimestamp); 
+8
source

You can pass strtotime string conditions to $faker->dateTimeBetween() .

 //ranging from today ending in 2 years $faker->dateTimeBetween('+0 days', '+2 years') //ranging from next week ending in 1 month $faker->dateTimeBetween('+1 week', '+1 month') //ranging from next sunday to next wednesday (if today is wednesday) $faker->dateTimeBetween('next sunday', 'next wednesday') 

see http://php.net/manual/en/function.strtotime.php for a complete list of usage and string combinations.

+12
source

Try the following:

 $faker -> dateTimeThisDecade($max = '+10 years') 
0
source

Source: https://habr.com/ru/post/989820/


All Articles