note 85973 modified in function.date by danbrown

From: Date: Fri, 26 Sep 2008 15:16:47 +0000
Subject: note 85973 modified in function.date by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-144756@lists.php.net to get a copy of this message
This is a code to convert RSS pubDate to a timestamp. A timestamp is an INT which is faster and easier to sort than VARCHAR. <?php function pubDate_to_timestamp($time){ //Thu, 21 Aug 2008 01:14:36 PDT //=> date("D, j M Y H:i:s T"); $time = explode(' ', $time); $chrono = explode(':', $time[4]); $month = array('Jan' => 1, 'Feb' => 2, 'Mar' => 3, 'Apr' => 4, 'May' => 5, 'Jun' => 6, 'Jul' => 7, 'Aug' => 8, 'Sep' => 9, 'Oct' => 10, 'Nov' => 11, 'Dec' => 12); $mktime = mktime($chrono[0], $chrono[1], $chrono[2], $month[$time[2]], $time[1], $time[3], $time[5]); return $mktime; } ?> --was-- This is a code to convert RSS pubDate to a timestamp. A timestamp is an INT which is faster and easier to sort than VARCHAR. function pubDate_to_timestamp($time){ //Thu, 21 Aug 2008 01:14:36 PDT //=> date("D, j M Y H:i:s T"); $time = explode(' ', $time); $chrono = explode(':', $time[4]); $month = array('Jan' => 1, 'Feb' => 2, 'Mar' => 3, 'Apr' => 4, 'May' => 5, 'Jun' => 6, 'Jul' => 7, 'Aug' => 8, 'Sep' => 9, 'Oct' => 10, 'Nov' => 11, 'Dec' => 12); $mktime = mktime($chrono[0], $chrono[1], $chrono[2], $month[$time[2]], $time[1], $time[3], $time[5]); return $mktime; } http://php.net/manual/en/function.date.php

« previous php.notes (#144756) next »