Noel Tock
Noel Tock

Reputation: 609

Convert Unix epoch timestamp to MySQL timestamp in PHP

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.

Upvotes: 3

Views: 3190

Answers (1)

SERPRO
SERPRO

Reputation: 10067

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

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

Upvotes: 7

Related Questions