【发布时间】:2013-03-20 20:15:29
【问题描述】:
试图解析 1942 年 5 月 5 日
-872726549
DatTime::__construct()
Failed to parse time string (-872726549) at position 7 (4):
Unexpected character
1970 年 1 月 1 日之前的所有日期都相同
1969 年 12 月 31 日有同样的错误
我在 windows 上使用 xampp,php 5.4
这会触发错误:
$topv=-872726549;
$compared_time=new DateTime($topv);
【问题讨论】:
-
您知道时间戳从 0 开始,到最大 2 的 32 次方结束吗?时间戳总是正整数。#
-
我遇到了
$date=$year.'-'.$month.'-'.$day.' '.date("H:i:s"); $datev=strtotime(date($date),time());的负值 -
你读过 DateTime 的文档吗?
public DateTime::__construct() ([ string $time = "now" [, DateTimeZone $timezone = NULL ]] )并且还明确指出:time: 'A date/time string. Valid formats are explained in Date and Time Formats.'