gpt4 book ai didi

php - date() 和 strftime() 在 Windows 和 Linux 上不一样。为什么?

转载 作者:行者123 更新时间:2023-12-03 19:41:42 25 4
gpt4 key购买 nike

为什么 Windows 不支持 date()strftime() 的某些选项?我认为与日期相关的任何东西都是每个系统都应该支持的。是因为日期内部存储的方式吗?

最佳答案

manual on date()指出两个区别:

  • 在 PHP 5.1.0 之前的 Windows 上,时间戳范围为 1970 到 2038。
  • 根据用户发表的评论,微秒开关无法在 Windows 上使用。

对于 strftime():

Not all conversion specifiers may be supported by your C library, in which case they will not be supported by PHP's strftime(). Additionally, not all platforms support negative timestamps, so your date range may be limited to no earlier than the Unix epoch. This means that %e, %T, %R and, %D (and possibly others) - as well as dates prior to Jan 1, 1970 - will not work on Windows, some Linux distributions, and a few other operating systems. For Windows systems, a complete overview of supported conversion specifiers can be found at » MSDN.

你是这个意思吗?好吧,原因已经解释过了,不支持负时间戳。我认为对此无能为力。

如果这给您带来了问题,您可能需要使用像 Zend_Date 这样的库。 .

关于php - date() 和 strftime() 在 Windows 和 Linux 上不一样。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2034242/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com