Converting a UNIX Timestamp to Formatted Date String

Utku Dalmaz picture Utku Dalmaz · Apr 6, 2012 · Viewed 470.6k times · Source

Using PHP, I want to convert UNIX timestamps to date strings similar to this: 2008-07-17T09:24:17Z

How do I convert a timestamp such as 1333699439 to 2008-07-17T09:24:17Z?

Answer

stewe picture stewe · Apr 6, 2012

Try gmdate like this:

<?php
$timestamp=1333699439;
echo gmdate("Y-m-d\TH:i:s\Z", $timestamp);
?>