我怎么才能在这个时间上再加30秒呢?
$time = date("m/d/Y h:i:s a", time());
我不确定该怎么做,因为它显示了很多不同的时间单位,而我只想添加30秒。
发布于 2010-06-16 19:40:40
$time = date("m/d/Y h:i:s a", time() + 30);
发布于 2010-06-16 19:42:43
如果你用的是php 5.3+,看看DateTime::add operations或者modify
,比这简单多了。
例如:
$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;
}
发布于 2010-06-16 20:08:58
使用strtotime怎么样?然后代码将是:
strtotime( '+30 second' );
https://stackoverflow.com/questions/3052865
复制相似问题