note 71283 added to function.mktime

From: Date: Tue, 21 Nov 2006 04:07:56 +0000
Subject: note 71283 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-119918@lists.php.net to get a copy of this message
<?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. ---- Server IP: 203.89.181.184 Probable Submitter: 203.109.245.204 ---- Manual Page -- http://www.php.net/manual/en/function.mktime.php Edit -- https://master.php.net/note/edit/71283 Del: integrated -- https://master.php.net/note/delete/71283/integrated Del: useless -- https://master.php.net/note/delete/71283/useless Del: bad code -- https://master.php.net/note/delete/71283/bad+code Del: spam -- https://master.php.net/note/delete/71283/spam Del: non-english -- https://master.php.net/note/delete/71283/non-english Del: in docs -- https://master.php.net/note/delete/71283/in+docs Del: other reasons-- https://master.php.net/note/delete/71283 Reject -- https://master.php.net/note/reject/71283 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119918) next »