note 71283 deleted from function.mktime by mazzanet
| From: | mazzanet@php.net | Date: | Tue, 21 Nov 2006 08:40:59 +0000 |
| Subject: | note 71283 deleted from function.mktime by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-119919@lists.php.net to get a copy of this message | ||
Note Submitter: tom [at] frogontop [dot] c0m
Reason: useless
----
<?php
function rssTimeToUnixtime($rssTime) {
preg_match_all('/([A-Za-z]{3}), ([0-9]{2}) ([A-Za-z]{3}) ([0-9]{4})
([0-9]{2}):([0-9]{2}):([0-9]{2}) (.*)/', $rssTime, $dateMatches);
$monthArray = array('Jan' => 1, 'Feb' => 2, 'Mar' => 3,
'Apr' => 4, 'May' => 5, 'Jun' => 6, 'July' => 7,
'Aug' => 8, 'Sep' => 9, 'Oct' => 10, 'Nov' =>
11, 'Dec' => 12);
return mktime($dateMatches[5][0], $dateMatches[6][0], $dateMatches[7][0],
$monthArray[$dateMatches[3][0]], $dateMatches[2][0], $dateMatches[4][0]);
}
?>
This will take a RSS timestamp, say "Mon, 20 Nov 2006 16:41:57 GMT" and convert it to a
unix timestamp.
Might not be 100% accurate due to timezones.