PHP Date Time Current Time Add Minutes

php

Question

Simple question but this is killing my time.

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

1
44
6/12/2009 9:27:52 AM

Accepted Answer

I think one of the best solutions and easiest is:

strtotime("+30 minutes")

Maybe it's not the most efficient but is one of the more understandable.

111
6/12/2009 1:59:25 PM

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

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon