RE: [PHP] literal dates
| From: | Ford, Mike | Date: | Fri, 03 Sep 2004 12:46:06 +0000 |
| Subject: | RE: [PHP] literal dates | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-195718@lists.php.net to get a copy of this message | ||
On 03 September 2004 06:46, Justin French wrote:
> If I use strtotime(), I'm handed back a GMT timestamp,
> whereas I need a
> *local* timestamp.
No such thing as a *local* timestamp. UNIX timestamps are in GMT by definition -- it's the
functions that work with them that do the timezone adjustments. (Compare mktime(12,0,0,9,1,2004)
and gmmktime(12,0,0,9,1,2004), for example.)
> Am I missing something here, I do I really need to know the
> GMT offset
> of every event?
My opinion on that would be a "Yes", if you're storing events that can take place in
multiple timezones.
Your only other option, which would effectively give you your "local timestamp", is to
treat every date/time entered as if it were GMT, and always use the gm*() functions (or force-add a
"GMT" marker to strings passed to strtotime()). That way, no timezone adjustments are
ever done, and any one user sees times as originally entered -- but you can't do cross-timezone
comparisons because they're not timezone adjusted. Oh, and you probably still need to do
manual tracking of DST.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211