note 62885 added to function.gmdate
| From: | gefiltefishee at comcast dot net | Date: | Sat, 11 Mar 2006 21:54:20 +0000 |
| Subject: | note 62885 added to function.gmdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-105287@lists.php.net to get a copy of this message | ||
I was struggling with how to get my browser to output MY local time using gmdate().
I figured it out and here's what you do (ASSUMING THE SERVER IS ON GMT, If not, just echo a
generic gmdate() without timezone setting and calculate the number of hours ahead or behind you are
of that time, convert it to seconds and add [for ahead] or subtract [for behind] that value to
time() ):
NOTE: these are US times [setlocale(LC_TIME, 'en_US')]
for Central Time (7 hours behind GMT):
gmdate("format", time()-(25200));
For Pacific Time (9 hours behind GMT):
gmdate("format", time()-(32400));
REMEMBER - THE VALUES ABOVE ASSUME THE SERVER IS ON GMT
I used the following gmdate() format:
"l, F jS, Y g:i a"
but you can use what you like ;)
Hope this helps!
----
Server IP: 146.231.115.1
Probable Submitter: 67.190.253.115
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.gmdate.php
Edit -- http://master.php.net/note/edit/62885
Del: integrated -- http://master.php.net/note/delete/62885/integrated
Del: useless -- http://master.php.net/note/delete/62885/useless
Del: bad code -- http://master.php.net/note/delete/62885/bad+code
Del: spam -- http://master.php.net/note/delete/62885/spam
Del: non-english -- http://master.php.net/note/delete/62885/non-english
Del: in docs -- http://master.php.net/note/delete/62885/in+docs
Del: other reasons-- http://master.php.net/note/delete/62885
Reject -- http://master.php.net/note/reject/62885
Search -- http://master.php.net/manage/user-notes.php