PHP round the time to the nearest 15 seconds

后端 未结 3 1782
遥遥无期
遥遥无期 2021-01-21 03:32

This is not a duplicate question, but involves a little understanding about time.

I need a solution to the following problem I have a number of specifically produced tim

3条回答
  •  Happy的楠姐
    2021-01-21 04:14

    Convert the date to seconds using strtotime and then just work in seconds.

    $seconds = strtotime($date);
    $seconds /= 15;
    $seconds = round($seconds);
    $seconds *= 15;
    $date = date("Y-m-d H:i:s", $seconds);
    

提交回复
热议问题