3

I have an issue whereby a client has some legacy environment (IIS 6 / PHP 5.0.1) and keeps getting the following error:

Warning: date() [function.date]: Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in" when using the date() function.

I need to find a way to convert my UNIX timestamp, i.e "1293559200" (28th of Dec, 2010) to something I can then pass on as a correct date.

random
  • 9,774
  • 10
  • 66
  • 83
Noel Tock
  • 609
  • 6
  • 13
  • Does he get this error for pre-1970 dates (i.e. negative timestamp?) Which PHP and IIS version is that? – Mchl Jan 25 '11 at 13:42
  • What version of PHP? Since 5.1.0, PHP on Windows has supported signed 32-bit dates from 13th Dec 1901 20:45:54 GMT to 19th Jan 2038 03:14:07 GMT – Mark Baker Jan 25 '11 at 13:44
  • Version 5.0.1. So you're saying if the client upgrades, he'll be a unix timestamp (i.e. 1293559200 ) via the date() function on an IIS server? Thank you! – Noel Tock Jan 25 '11 at 14:36
  • PHP 5.0.1 // Microsoft-IIS/6.0 – Noel Tock Jan 25 '11 at 14:37

1 Answers1

7
SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(), '%Y-%m-%d %H:%i:%s');

Where you can replace UNIX_TIMESTAMP() with your timestamp value.

SERPRO
  • 10,015
  • 8
  • 46
  • 63