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

标签 php date cross-platform strftime

为什么 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/

相关文章:

javascript - Laravel 发送 Json 到 Controller

php - 如何在 Doctrine 中使用mysql变量

php - 如何显示月份、日期和当前时间加十二个小时?

date - Grails日期类型

cross-platform - Xamarin 支持哪些平台?

android - Xamarin Listview 分组

java - Volley 不向 PHP 发送变量

php - 如何在 WooCommerce 管理订单列表上创建过滤器下拉菜单?

ruby-on-rails - 如何在 Ruby 中转换日期格式

c++ - 标准库中是否有跨平台的头文件提供对当前时间的访问?