HI我需要在时间上增加8小时,我的格式如下
$t = microtime(true);
$micro = sprintf("%06d",($t - floor($t)) * 1000000);
$d = new DateTime( date('Y-m-d H:i:s.'.$micro, $t) );
$d->format("Y-m-d H:i:s.u") // 2015-03-02 07:37:18.715271
我使用这种格式是因为我还需要显示微秒。现在,我需要在其中添加8小时。你能建议我怎么做吗。
感谢
$t = microtime(true);
$micro = sprintf("%06d",($t - floor($t)) * 1000000);
$d = new DateTime( date('Y-m-d H:i:s.'.$micro, $t) );
print $date = $d->format("Y-m-d H:i:s.u");
print $new_time = date("Y-m-d H:i:s".$micro, strtotime($date.'+8 hours'));