note 74495 added to function.strtotime
| From: | ChrysBader at osu1 dot php dot net | Date: | Fri, 13 Apr 2007 23:16:53 +0000 |
| Subject: | note 74495 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125370@lists.php.net to get a copy of this message | ||
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));
?>
----
Server IP: 64.71.164.2
Probable Submitter: 207.172.209.44
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- https://master.php.net/note/edit/74495
Del: integrated -- https://master.php.net/note/delete/74495/integrated
Del: useless -- https://master.php.net/note/delete/74495/useless
Del: bad code -- https://master.php.net/note/delete/74495/bad+code
Del: spam -- https://master.php.net/note/delete/74495/spam
Del: non-english -- https://master.php.net/note/delete/74495/non-english
Del: in docs -- https://master.php.net/note/delete/74495/in+docs
Del: other reasons-- https://master.php.net/note/delete/74495
Reject -- https://master.php.net/note/reject/74495
Search -- https://master.php.net/manage/user-notes.php