我想存储开始时间&结束时间,并计算两次之间的总时间差。有一段时间,由于这个问题,我得到了像-1 min -24 sec
这样的负面时间。。。
如果我是回显这个代码
date('Y-m-d h:m:s',1345810203);
我得到的答案是2012-08-24 02:08:03
,但我回显了这个代码
strtotime('2012-08-24 02:08:03');
我得到的答案是1345766883
。
如果时间是1345810167
或1345810187
,则在strtotime&date()。
问题出在哪里?
您的格式错误。
m
是Numeric representation of a month, with leading zeros
i
是Minutes with leading zeros
使用以下格式:
'Y-m-d h:i:s'
参考编号:http://php.net/manual/en/function.date.php