Does PHP have an inverse of the date() function (other than strtotime())?

PHP 5.4+ will print 1359674625

echo date_create_from_format('j/n/Y G:i:s','1/2/2013 1:23:45')->getTimestamp();

You would typically use strtotime for that:

echo strtotime('2011-05-05 17:29:34');

From the manual:

strtotime — Parse about any English textual datetime description into a Unix timestamp

See valid date and time formats to be sure that the string you are passing in will be parsed correctly.


The real answer to this question the way I mean it is http://www.php.net/manual/en/datetime.createfromformat.php

    $date = date_create_from_format('j-M-Y', '15-Feb-2009');
    echo date_format($date, 'Y-m-d'); // 2009-02-15

Tags:

Php

Date