Add 30 seconds to the time with PHP
What about using strtotime? The code would then be:
strtotime( '+30 second' );
If you're using php 5.3+, check out the DateTime::add operations or modify
, really much easier than this.
For example:
$startTime = new DateTime("09:00:00");
$endTime = new DateTime("19:00:00");
while($startTime < $endTime) {
$startTime->modify('+30 minutes'); // can be seconds, hours.. etc
echo $startTime->format('H:i:s')."<br>";
break;
}
$time = date("m/d/Y h:i:s a", time() + 30);
$time = date("m/d/Y h:i:s a", time() + 30);
//or
$time = date("m/d/Y h:i:s a", strtotime("+30 seconds"));