开发者

date() and strftime() not same on windows and Linux. Why?

开发者 https://www.devze.com 2022-12-15 18:39 出处:网络
Why are some options to date() and strftime() not supported on Windows? I though anything related to date is something that every system should support. Is it becaus开发者_如何转开发e of the way the d

Why are some options to date() and strftime() not supported on Windows? I though anything related to date is something that every system should support. Is it becaus开发者_如何转开发e of the way the date is internally stored?


The manual on date() points out two differences:

  • Timestamps used to range from 1970 to 2038 on Windows before PHP 5.1.0.
  • According to a User Contributed Comment, the Microseconds switch can't be used on Windows.

and for 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.

is that what you mean? Well, the reasons are explained there already, no support for negative timestamps. I don't think much can be done about that.

If that is giving you problems, you may want to go with a library like Zend_Date.


It's because date and strftime are just thin wrappers around underlying system functions, so that they accept only those functions that the operating system supports.

http://linux.die.net/man/3/strftime
http://msdn.microsoft.com/en-us/library/fe06s4ak%28VS.71%29.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消