phpunix-timestamp

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?


Solution

  • Try gmdate like this:

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