confusion with adding 2 time values

前端 未结 3 1743
不思量自难忘°
不思量自难忘° 2021-01-23 06:19

Basically this whole time stuff is frustrating me, I am new to programming so I do apologise if I am asking a stupid question.

I have a MySQL time() stored in my databas

3条回答
  •  我在风中等你
    2021-01-23 06:37

    strtotime converts it to a unix time stamp. It DOES NOT represent six hours. It represents 6AM today. You should work with seconds:

    $duration = '06:00:00';
    $duration_array = explode(':', $duration);
    
    $length = ((int)$duration_array[0] * 3600) + ((int)$duration_array[1] * 60) + (int)$duration_array[2];
    $target = $length + time();
    

提交回复
热议问题