How do I generate a random time interval and add it to a mysql datetime using php?

前端 未结 3 2105
说谎
说谎 2021-01-03 09:11

I have many rows in mysql table with datetime\'s in the format of:

2008-12-08 04:16:51 etc

I\'d like to generate a random time interval of

3条回答
  •  太阳男子
    2021-01-03 09:39

    easier way.

    $new_date = date('Y-m-d h:i:s', strtotime('2008-12-08 04:16:51 +'.rand(30, 60 * 60 * 24 * 3).' seconds'));
    

提交回复
热议问题