PHP Date Time Current Time Add Minutes

前端 未结 12 2149
忘掉有多难
忘掉有多难 2020-12-01 07:21

Simple question but this is killing my time.

Any simple solution to add 30 minutes to current time in php with GMT+8?

12条回答
  •  粉色の甜心
    2020-12-01 07:45

    This is an old question that seems answered, but as someone pointed out above, if you use the DateTime class and PHP < 5.3.0, you can't use the add method, but you can use modify:

    $date = new DateTime();
    $date->modify("+30 minutes"); //or whatever value you want
    

提交回复
热议问题