note 42450 deleted from function.date by tomsommer
| From: | tomsommer@php.net | Date: | Mon, 09 Aug 2004 01:21:14 +0000 |
| Subject: | note 42450 deleted from function.date by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74273@lists.php.net to get a copy of this message | ||
Note Submitter: jseng@pobox.org.sg
----
To use the ISO 8601 date spec in PHP <5, you *cannot* simply use the string format
"Y-m-d\TH:i:sO" because the timezone format in ISO 8601 is in the format +XX:XX not +XXXX
returned by 'O'
Use this function instead:
function iso8601_date($time) {
$tzd = date('O',$time);
$tzd = $tzd[0] . str_pad((int) ($tzd/100),2,"0",STR_PAD_LEFT) .
str_pad((int) ($tzd%100),2,"0",STR_PAD_LEFT);
$date = date('Y-m-d\TG:i:s',$time).$tzd; return $date;
}