note 85509 added to function.date
| From: | jonathancnewcomb at msn dot com | Date: | Wed, 03 Sep 2008 05:03:52 +0000 |
| Subject: | note 85509 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144101@lists.php.net to get a copy of this message | ||
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;
}
----
Server IP: 64.71.164.2
Probable Submitter: 76.185.36.48
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/85509
Del: integrated -- https://master.php.net/note/delete/85509/integrated
Del: useless -- https://master.php.net/note/delete/85509/useless
Del: bad code -- https://master.php.net/note/delete/85509/bad+code
Del: spam -- https://master.php.net/note/delete/85509/spam
Del: non-english -- https://master.php.net/note/delete/85509/non-english
Del: in docs -- https://master.php.net/note/delete/85509/in+docs
Del: other reasons-- https://master.php.net/note/delete/85509
Reject -- https://master.php.net/note/reject/85509
Search -- https://master.php.net/manage/user-notes.php