日期时间PHP的致命错误具有负时间戳
试图解析1942年5月5日日期时间PHP的致命错误具有负时间戳
-872726549
DatTime::__construct()
Failed to parse time string (-872726549) at position 7 (4):
Unexpected character
同样对于前1 1 1970
1969年12月31日有相同的错误所有daties
我在Windows上使用XAMPP,PHP 5.4
这三ggers错误:
$topv=-872726549;
$compared_time=new DateTime($topv);
根据文档中,你应该做这样的:
$topv='1930-08-09';
$compared_time=new DateTime($topv);
对,它应该是'$ date = $ year。''。$ month。''。$ day。' ” .date( “H:I:S”); $ DATEV =的strtotime(日期($日期),时间()); $ datev = date('ymd H:i:s',$ datev);'并且没有错误,谢谢,它必须处理一个会检查strpos - 并返回其他值而不是日期格式的函数 – lbennet 2013-03-20 20:33:36
如果你需要两个日期之间的差异,你可以用一些DateTime特定功能来做到这一点 – ITroubs 2013-03-20 20:35:58
请看这里:http://www.php.net/manual/en/datetime.diff.php – ITroubs 2013-03-20 20:36:30
你知道,时间戳在0和结束开始在2最大的32次幂?时间戳总是正整数。# – ITroubs 2013-03-20 20:18:09
我遇到了'$ date = $ year .'-'。$ month' - '。$ day'的负值。 ” .date( “H:I:S”); $ datev = strtotime(date($ date),time());' – lbennet 2013-03-20 20:19:24
您是否阅读过DateTime的文档? 'public DateTime :: __ construct()([string $ time =“now”[,DateTimeZone $ timezone = NULL]])'它也明确指出:'time:'日期/时间字符串。有效的格式在日期和时间格式中解释。'' – ITroubs 2013-03-20 20:25:32