Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法转换数据库值“0”;1876-01-01 00:00:00-00:00:00“;输入日期时间_Php_Postgresql_Datetime_Doctrine Orm - Fatal编程技术网

Php 无法转换数据库值“0”;1876-01-01 00:00:00-00:00:00“;输入日期时间

Php 无法转换数据库值“0”;1876-01-01 00:00:00-00:00:00“;输入日期时间,php,postgresql,datetime,doctrine-orm,Php,Postgresql,Datetime,Doctrine Orm,为什么教义不喜欢古老的日期 Exception was thrown : Could not convert database value "1876-01-01 00:00:00-00:00:00" to Doctrine Type datetime 还有一个: Exception was thrown : Could not convert database value "0000-00-00 00:00:00-00:00:00" to Doctrine Type datetime 在我

为什么教义不喜欢古老的日期

Exception was thrown : Could not convert database value "1876-01-01 00:00:00-00:00:00" to Doctrine Type datetime
还有一个:

Exception was thrown : Could not convert database value "0000-00-00 00:00:00-00:00:00" to Doctrine Type datetime
在我的实体中,我确实覆盖了
datetime
datetimetz

Type::overrideType('datetime', 'Doctrine\DBAL\Types\VarDateTimeType');
Type::overrideType('datetimetz', 'Doctrine\DBAL\Types\VarDateTimeType');
如果我将日期更新为
1976-01-01 00:00:00-00:00:00

更新:

因此,我运行的是Ubuntu 12.04 64位,我也知道通过这些测试,我有64位的工作时间:

strotime()在运行的32位和64位系统上生成不同的输出 PHP 5.3.3(如前所述)。这会影响“零日期” (“0000-00-00:00:00”)以及传统日期以外的日期 日期范围

测试:

strtotime("0000-00-00 00:00:00") returns FALSE on a 32 bit system.
strtotime("0000-00-00 00:00:00") returns -62169955200 on a 64 bit system.
执行echo strotime时(“0000-00-00:00:00”)我得到这个:

php time_test.php -62169966000

那么条令有问题吗?

PHP的纪元是1970年还是1901年取决于您的系统

从PHP手册:

时间戳的有效范围通常从1901年12月13日星期五开始 20:45:54格林威治标准时间至2038年1月19日星期二03:14:07格林威治标准时间(以下是日期 对应于32位有符号字符串的最小值和最大值 整数)。但是,在PHP5.1.0之前,此范围仅限于 01-01-1970至19-01-2038在某些系统(例如Windows)上


32位
时间\u t
值只能表示1901年底到2038年初之间的日期。要处理该范围之外的日期,需要64位
时间。距离“世界末日”还有不到25年的时间了——当基于1970-01-01 00:00:00+00:00纪元的32位
time\t
值用完时。@JonathanLeffler有什么地方我可以设置或告诉条令使用64位time\t?根本不知道条令,我不确定。这将是一个编译时问题;您需要一个64位的PHP和Doctrine构建。如果您使用的是32位专用系统,则可能会卡住。如果您使用的是64位系统(也就是说,硬件是x86_64或其他一些64位芯片),那么您可能可以重建所有64位系统,并且它可能正常工作。然而,这不是一项微不足道的任务。(对于“重建”,您可以阅读“重建或下载预构建”-您几乎肯定需要在64位系统上安装64位软件。)我不认为这些是postgresql时间戳。当然0000-00-00不是有效日期。@RichardHuxton否,但我可以在Postgresql中默认为0000-00-00时间戳/日期时间