Adding time in PHP

前端 未结 8 1078
别那么骄傲
别那么骄傲 2020-12-22 10:37

I am pulling a datetime from a mysql db and i would like to add X hours to it then compare it to the current time. So far i got

$dateNow = strtotime(date(\'Y         


        
8条回答
  •  自闭症患者
    2020-12-22 11:11

    time() and strtotime() result in unix timestamps in seconds, so you can do something like the following, provided your db and do your comparison:

    $fourHours = 60 * 60 * 4;
    $futureTime = time() + $fourHours;
    

提交回复
热议问题