doubi4617 2012-02-05 21:03
浏览 168
已采纳

什么会导致php的strtotime不适用于2099年的约会?

I have three servers, doing the following on all three servers:

echo strtotime('2099-12-31');
echo strtotime(date('Y-m-d'));

gets me:

Server #1: (php 5.3.8, 64bit)

4102376400
1328418000

Server 2: (php 5.3.2, 32bit)

**[nothing]**
1328418000

Server #3: (php 5.3.2 - 64bit I thought it might be a php version issue)

4102376400
1328418000

What would cause strtotime to fail on one of the servers but not the others? All three have the same Default timezone and date.timezone settings in php.ini (not sure if that would have an effect or not). I also turned on errors and I'm not seeing anything.

  • 写回答

2条回答 默认 最新

  • dongqun1656 2012-02-05 21:07
    关注

    Probably it is a 32-bit issue. It works just fine on my 64-Bit Server, but my 32-bit Ubuntu returns false on strtotime('2099-12-31')

    For further information see this note in the manual (highlighting by me):

    The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems. PHP 5.1.0 and newer versions overcome this limitation though.

    For 64-bit versions of PHP, the valid range of a timestamp is effectively infinite, as 64 bits can represent approximately 293 billion years in either direction.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 Windows Server 2016利用兩張網卡處理兩個不同網絡
  • ¥15 Python中knn问题
  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源