Skip to content
Advertisement

Converting a UNIX Timestamp to Formatted Date String

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?

Advertisement

Answer

Try gmdate like this:

<?php
$timestamp=1333699439;
echo gmdate("Y-m-dTH:i:sZ", $timestamp);
?>
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement