note 22260 added to function.imap-header
| From: | dinesh@php.net | Date: | Wed, 12 Jun 2002 13:31:59 +0000 |
| Subject: | note 22260 added to function.imap-header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-31737@lists.php.net to get a copy of this message | ||
To convert a RFC 822 date into an UNIXTIMESTAMP, you can use this code: (if you're making your
own POP3 include file ;P)
(exemple of a date: Sat, 01 Jun 2002 14:40:16 +0200)
$buffer = substr($buffer, 5); // On vire "DAY, "
$day = substr($buffer, 0, 2);
$month = substr($buffer, 3, 3);
switch ($month) {
case 'Jan':
$month = "1";
break;
case 'Feb':
$month = "2";
break;
case 'Mar':
$month = "3";
break;
case 'Apr':
$month = "4";
break;
case 'May':
$month = "5";
break;
case 'Jun':
$month = "6";
break;
case 'Jul':
$month = "7";
break;
case 'Aug':
$month = "8";
break;
case 'Sep':
$month = "9";
break;
case 'Oct':
$month = "10";
break;
case 'Nov':
$month = "11";
break;
case 'Dec':
$month = "12";
break;
}
$year = substr($buffer, 7, 4);
$buffer = substr($buffer, 12); // On vire le "01 Jun 2002 "
// 14:40:16 +0200
$hour = substr($buffer, 0, 2);
$minute = substr($buffer, 3, 2);
$seconde = substr($buffer, 6, 2);
$buffer = substr($buffer, 9); // On vire le "14:40:16 "
// +0200
$operation = substr($buffer, 0, 1);
$decalage = substr($buffer, 1, 2);
if ($operation == "+") $hour = $hour - $decalage;
elseif ($operation == "-") $hour = $hour + $decalage;
$time = gmmktime($hour, $minute, $seconde, $month, $day, $year);
And $time is the UNIXTIMESTAMP of the date.
You can now use date("YOUR FORMAT", $time) to re-convert your date ;P
--
http://www.php.net/manual/en/function.imap-header.php
http://master.php.net/manage/user-notes.php?action=edit+22260
http://master.php.net/manage/user-notes.php?action=delete+22260
http://master.php.net/manage/user-notes.php?action=reject+22260