问题描述
我知道这个问题很受欢迎
I know this question is very popular
在这里问PHP:strtotime 在未来日期返回 false?和这里 我如何在 PHP 中处理 1900 年之前的日期?
能否请您确认我的选择:
Could you please confirm my choices:
升级到 64 位架构
Upgrade to a 64bit architecture
用 DateTime + DateInterval 替换 strtotime 调用我们不能调用 DateTime->getTimestamp 但我们可以使用 DateInterval 来计算差异
Replace the strtotime calls by DateTime + DateIntervalWe can't call DateTime->getTimestamp but we can use DateInterval to calculate the diff
我还有其他选择吗?不幸的是,我无法选择选项 2,因为我依赖 ORM(Propel)+ 使用 strtotime 的大量遗留代码.重构这些东西 + 自定义 ORM 生成器可能比升级到 64 位更昂贵.
Do I have any other options?Unfortunately, I can't pick option 2 because I am relying on ORM (Propel) + a lot of legacy code using strtotime. Refactoring this stuff + customizing the ORM generators could be more expensive than upgrading to 64bits.
如果有人可以确认或提供任何其他选项,那将不胜感激.
If anybody could confirm or offer any other options, that would be really appreciated.
谢谢
日期格式为标准 yyyy-mm-dd
The date format is the standard yyyy-mm-dd
PHP 5.3.2 版
PHP Version 5.3.2
推荐答案
AFAIK,您仅限于这两种解决方案.
AFAIK, you are limited to these two solutions.
如果你负担得起,你应该更新到 64 位系统,如果它解决了一个问题,那就更好了.
You should update to 64-bit system if you can afford it, and if it solves a problem then that's better.
只需要检查:http://php.net/manual/en/function.runkit-function-redefine.php您可能可以尝试重新定义 strtotime()
以处理 1901 年之前的日期.
Just had to check:http://php.net/manual/en/function.runkit-function-redefine.phpYou could probably try and redefine strtotime()
to work with dates prior to 1901.
这篇关于PHP strtotime 对于小于 1900 的日期返回 false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!