php - 带负时间戳的 datetime php fatal error

标签 php datetime timestamp

试图解析 1942 年 5 月 5 日

-872726549

DatTime::__construct()

Failed to parse time string (-872726549) at position 7 (4):
Unexpected character

1 1 1970 之前的所有日期都相同

1969年12月31日有同样的错误

我在 windows 上使用 xampp,php 5.4

这会触发错误:

$topv=-872726549;
$compared_time=new DateTime($topv);

最佳答案

根据文档,您应该这样做:

$topv='1930-08-09';
$compared_time=new DateTime($topv);

关于php - 带负时间戳的 datetime php fatal error ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15533781/

相关文章:

PHP print_r 清除 mysqli 连接对象的状态?

php - 需要帮助.. 有人可以告诉我为什么查询没有执行吗?

python - Pandas 时间戳索引到日期字符串列表

scala - 将 UTC unix 时间转换为同一时区的时间戳

python - 什么正则表达式匹配这种类型的时间戳

php - 将多条记录从一个表复制到另一个表(相同结构)(PHP/MySQL)

javascript - jQuery 拖放表行排序不起作用

c# - yyyyMMddtt 中的 DateTime.ParseExact 错误

c# - 字符串到日期时间?扩展 Convert.* 或更好的东西

javascript - 我如何从手机上解读这些奇怪的 JavaScript 时间戳?