note 85509 deleted from function.date by tularis
| From: | tularis@php.net | Date: | Wed, 03 Sep 2008 07:17:43 +0000 |
| Subject: | note 85509 deleted from function.date by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-144104@lists.php.net to get a copy of this message | ||
Note Submitter: jonathancnewcomb at msn dot com
----
I had a question come to my inbox today from a newer developer. He asked me why his conversion from
the Unix Epoch to a date format wasn't working correctly. Here is the answer:
The Unix Epoch date is 1970-01-01 00:00:00 GMT
The date function goes off the server time zone. Heres a simple function to help
function epoch2date($format, $epoch){
// Function by Jonathan Newcomb (jonathancnewcomb@msn.com)
$gmt = substr(date('O'), 0, 3);
$ret = date($format, mktime($gmt, 0, 0, 1, 1, 1970));
return $ret;
}