note 74495 deleted from function.strtotime by derick
| From: | derick@php.net | Date: | Sun, 15 Jul 2007 12:35:36 +0000 |
| Subject: | note 74495 deleted from function.strtotime by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-128546@lists.php.net to get a copy of this message | ||
Note Submitter: Chrys Bader
----
strtotime in PHP 4 doesn't support RFC3339 time, which is used in some RSS feeds (specifically
Atom)
I have written a small bit of code to translate it into a date that strtotime will convert.
<?php
$rfc3339 = "2007-04-13T09:06:45.491-07:00"; // Sample taken from Google's Atom feed
$tmp = str_replace( "T", " ", $rfc3339); // Remove the T
$tmp = ereg_replace("(\.[0-9]{1,})?", "", $tmp); // Remove the decimal and any
numbers after it
$datetime = substr($tmp, 0, 19); // Grab the datetime part of the string
$timezone = str_replace(":", "", substr($tmp, 19, 6)); // Grab the timezone,
(-/+0000) PHP 4 doesn't support the colon
echo date("Y-m-d H:i:s O", strtotime($datetime . " " . $timezone));
?>