Parsing HTTP 'Last-Modified' String Date in PHP

I use FileAPIto get the HTTP header of the Last-Modified time file, which returns the following line:

Fri Oct 25 2013 12:04:10 GMT+0100 (GMT Daylight Time)

Then it is sent to PHP, and I need it to convert to something reasonable, preferably a timestamp. Before you offer, strtotime()returns FALSE.

It does not seem to find an answer anywhere.

+4
source share
2 answers

, 5.3.0 DateTime::createFromFormat(). , , , +. , , , GMT+0100.

:

$str = "Fri Oct 25 2013 12:04:10 GMT+0100 (GMT Daylight Time)";
$fmt = 'D M d Y H:i:s O+';

$datetime = DateTime::createFromFormat($fmt, $str);
echo $datetime->getTimestamp();

:

1382699050
+6

, - , strtotime @Marcell, .

0

All Articles