Search code examples
phplaraveltimelimitfaker

Laravel, Faker - generate timestamp before certain time?


Is there a way to generate time between, let's say, 00:00:00 and 15:00:00 in Faker? I tried this:

$time   = $faker->time( 'H:i:s', '15:00:00' );

but it doesn't seem to work. I keep getting values between 00:00:00 and 23:59:59


Solution

  • No, there is no way in Faker to achieve limit on the time part.

    But forget faker for this little task:

     date('H:i:s', rand(1,54000)); // 00:00:00 - 15:00:00