Angad Dubey Angad Dubey - 7 months ago 34
PHP Question

How to get future date in Faker

How do I get future dates with:

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

dateTime($max = 'now')


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

Answer

Try passing a unix timestamp for $max.

$unixTimestap = '1461067200'; // = 2016-04-19T12:00:00+00:00 in ISO 8601

echo $faker->dateTime($unixTimestamp);

echo $faker->date('Y-m-d', $unixTimestamp);

// for all rows 
$faker->dateTimeBetween('now', $unixTimestamp);
Comments