|
Posted by C. on 10/10/07 11:57
On 10 Oct, 12:03, Ben Bradley <no...@nowhere.net> wrote:
>
> My question relates to what the best way is to handle dates/times with
> regards to daylight savings time.
> And we've managed to get ourselves confused over it all in the process.
>
> At the moment we've been storing all dates/times as Unix timestamps in
> our MySQL database, as a standard integer field. Which we noticed was
> the same way phpBB does it, so it can't be a bad idea.
>
Not the way I'd do it - Unix timestamps only operate for a realtively
narrow timeband. I'd strongly recommend you use MySQL DATETIME fields
and format them from Zulu/UTC/GMT (your truly predates the Unix
epoch).
Last time I looked, MySQL handling of timezones was a bit ropey (but
the format allows for dates from year 0000 to year 9999) so you might
want to go via Unix timestamp to get back to a local time using
set_locale() and date().
> Here's my questions:
> 1) When we're in BST (British Summer Time) which is 1hr ahead of GMT,
> does that function provide an automatic correction?
>
It does on Unix/Linux if the Locale is set correctly and the TZ files
are installed.
> 2) The Default timezone setting in our php.ini file (as discovered from
> phpinfo) is currently Europe/London
> Do I need to change any timezone of Apache or MySQL on our server from
> BST to GMT when the clocks change, in order to make sure we're storing
> accurate timestamps with our data?
>
Certainly for Apache on *nix, it logs in GMT by default.
HTH
C.
Navigation:
[Reply to this message]
|