0

how to get Random date between 2 date values using php ?

I am coding an application where i need to assign random date between two fixed timestamps

how i can achieve this using php i've searched first but only found the answer for php And how can add i values in gd library

Kasun
  • 11
  • 1
  • Please show us what are you trying. – Ashraful Karim Miraz Oct 17 '17 at 20:07
  • $datestart = strtotime('2009-12-10');//you can change it to your timestamp; $dateend = strtotime('2009-12-31');//you can change it to your timestamp; $daystep = 86400; $datebetween = abs(($dateend - $datestart) / $daystep); $randomday = rand(0, $datebetween); echo "\$randomday: $randomday\n"; echo date("Y-m-d", $datestart + ($randomday * $daystep)) . "\n"; – Kasun Oct 17 '17 at 20:09
  • You are asking "how to get Random date between 2 date values using php" and then you write "how i can achieve this using php i've searched first but only found the answer for php". Please clarify. – louisfischer Oct 17 '17 at 20:55
  • GD library is for manipulating images with PHP. Are you trying to create an imaged with the random date you generate? – John Baker Oct 17 '17 at 21:43
  • Check out this answer: https://stackoverflow.com/questions/1972712/how-to-generate-random-date-between-two-dates-using-php/1972717#1972717 – Mirza Sisic Oct 17 '17 at 23:02
  • I dont knw how to do it. Can u tel how to do it? Please – Kasun Oct 18 '17 at 01:22

0 Answers0