note 52061 added to function.date
| From: | php at webparlour dot com | Date: | Wed, 20 Apr 2005 12:12:38 +0000 |
| Subject: | note 52061 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-88255@lists.php.net to get a copy of this message | ||
This may be ULTRA SIMPLISTIC, but having this example would have saved me (a PHP newbie) some time
trying to figure out how to adjust the local server time to a different local time.
Essentially, I started out with:
$appdate = date("F jS Y, h:iA.");
Which captures the *local server time* in $appdate:
April 20th 2005, 04:44AM.
BUT...
The *local time* I needed reflected in the variable is 3 hours later. To accomplish this very
simply, add the "time()" modifier like so:
$appdate = date("F jS Y, h:iA.", time() + 10800);
Which captures the *ADJUSTED local server time* in $appdate:
April 20th 2005, 07:44AM.
So, adding " time() + 10800" to the normal Date() function ADDS 3 hours (10800 seconds!)
to the local server time.
Hope this helps others struggling to make this very basic adjustment.
Cheers,
Jem
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+52061
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52061&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52061&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52061&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52061&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52061&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+52061&report=yes
Search -- http://master.php.net/manage/user-notes.php