note 47094 added to function.date
| From: | tbellefy at yahoo dot com | Date: | Tue, 02 Nov 2004 16:58:39 +0000 |
| Subject: | note 47094 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-79511@lists.php.net to get a copy of this message | ||
In Reply to "post at penest dot no"
"post at penest dot no" wrote:
I needed to change the time to the correct local time for inserting it with now() in a mysql update
query.
I too have that problem. My server and my local time is -8 from GMT.....Hmmm....
Displayed without local time:
<?php
echo date("l dS of F Y H:i:s A");
// Returns: Tuesday 02nd of November 2004 16:42:40 PM
// This is wrong. 8 hours off.
?>
That displays GMT though.... I need my local time! So here goes:
<?php
// I am -8 hours from GMT:
$now = mktime(date("H")-8, date("i"), date("s"), date("m"),
date("d"), date("Y"));
echo date("l dS of F Y H:i:s A",$now);
// Returns: Tuesday 02nd of November 2004 08:42:40 AM
// This is correct!
?>
Hope this helps...
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47094
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47094&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47094&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47094&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47094&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47094&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47094&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47094&report=yes
Search -- http://master.php.net/manage/user-notes.php