Add time in PHP

前端 未结 4 486
予麋鹿
予麋鹿 2020-12-21 14:45

How can I add a given number of time in PHP?

Below is are three time variables I would like to add:

time1: \"00:02:00\"
time2: \"00:15:00\"
time3: \"         


        
4条回答
  •  猫巷女王i
    2020-12-21 15:21

    Change from h into H.

    h => 12-hour format of an hour with leading zeros

    H => 24-hour format of an hour with leading zeros

    Try

    echo date('H:i:s', strtotime('00:02:00') + strtotime('00:15:00') + strtotime('00:08:00'));
    

    Reference

提交回复
热议问题