Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Getting a client and server to agree on UTC time [SOLVED]
- Date: Sun, 19 Dec 2010 18:38:45 +0900
- From: Edmund Edgar <lists@example.com>
- Subject: Re: [tlug] Getting a client and server to agree on UTC time [SOLVED]
- References: <4D0DA713.7060006@example.com> <4D0DB8D6.30106@example.com> <4D0DCA7D.5050501@example.com>
On 19 December 2010 18:03, Dave M G <dave@example.com> wrote: > On the PHP side, the key was date_default_timezone_set("UTC"). That > cleared up some weird results I was getting by just using time() on its own. Glad you got it sorted out. But just to clarify this in case this, and the example Darren posted, gives somebody the wrong idea (or to give some kind person a chance to fix my understanding of this if I'm wrong): In PHP, time() always returns a UTC timestamp. It doesn't matter what you do with date_default_timezone_set(). The default timezone can be anything you like - time() will always return the same number at any given instant. This is the point of the example Darren quoted from the comments to the PHP manual: They set it to a couple of different things, and proved it returned the same number either way. What date_default_timezone_set affects is things like date() and mktime() that deal with converting UTC timestamps into human-readable dates and back again. Because these functions deal with human-readable dates and humans like to work with their local time, they also take account of the timezone. The alternative functions gmdate() and gmmktime() will give you UTC-based human-readable dates that ignore the default timezone. (If you find these last two functions helpful, there's a good chance you're doing something wrong.) If date_default_timezone_set() helped you here, it was probably actually fixing something you were doing with date() elsewhere in the script. -- Edmund Edgar Founder, KK Social Minds Educational Technology for the Web and Virtual Worlds ed@example.com +81 090 3912 3380 Skype: edmundedgar Second Life: Edmund Earp Linked In: edmundedgar Twitter: @edmundedgar http://www.socialminds.jp
- References:
- [tlug] Getting a client and server to agree on UTC time
- From: Dave M G
- Re: [tlug] Getting a client and server to agree on UTC time
- From: Darren Cook
- Re: [tlug] Getting a client and server to agree on UTC time [SOLVED]
- From: Dave M G
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Getting a client and server to agree on UTC time [SOLVED]
- Next by Date: [tlug] [OT] Payment gateways in Japan.
- Previous by thread: Re: [tlug] Getting a client and server to agree on UTC time [SOLVED]
- Next by thread: [tlug] [OT] Payment gateways in Japan.
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links