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条)

报告相同问题?

悬赏问题

  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染