Question

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 because of the way the date is internally stored?

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top