Sagewire Logo

Running an intranet PHP server... handling time in scripts

2 Message(s) by 2 Author(s) originally posted in php language


From: Ben Bradley Date:   Wednesday, October 10, 2007
Hi everyone

We're in the process of setting up an intranet solution using Apache ,
PHP and MySQL.
Currently it's all running on windows server 2000 but once we're closer
to completion we'll move all this over to Linux.

My question relates to what the best way is to handle date s/times with
regards to daylight savings time.
And we have managed to get ourselves confused over it all in the process.

At the moment we have 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 not be a bad idea.

At the moment all our users are in our UK office

But when we convert those values to readable dates, we usually use the
PHP date command:
date('j M y H:i', $timestamp);At the moment running that using the current time does return the
correct values.

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?

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 clock s change, in order to make sure we're storing
accurate timestamps with our data?

3) Our Windows 2000 Server is set to GMT timezone, and the box is
checked for Automatically adjust clock for daylight saving changes
Also we've it synchronising time using NTP with our local IPCop
firewall box, which itself syncs from 0.uk.pool.ntp.org and uk.pool.ntp.org
Is there anything we need to be doing on the server when the clocks
change, to ensure we're getting correct values?We were trying to think through all this earlier today, and just got
ourselves totally confused in the end.
So I'd appreciate it if someone can give us some advice and help us work
through our confusion.Thanks
Ben


From: C. Date:   Wednesday, October 10, 2007
wrote in message:
My question relates to what the best way is to handle dates/times with
regards to daylight savings time.
And we have managed to get ourselves confused over it all in the process.
At the moment we have 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 not 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.



Next Message: time


Blogs related to Running an intranet PHP server... handling time in scripts

Updating AS/400 Linked Server Tables from SQL Server ...
SPROC only running first step of DTS package - So I have this stored procedure i've created that runs a DTS package. I need it to work this way because I need to be able to use PHP to run my DTS packge. I decided to do it using an OLE ...

[fm-news] Newsletter for Sunday, October 07th 2007
command-line and a PHP interface. It works with both the standard hierarchical trees and the new and fashionable tagged bookmarks. It was developed as a way to interface both representation systems. SRESI can use Del.icio.us, Mozilla, ...

85 PHP Scripts
70) PHP-based Instant Photo Gallery Script This script is a tool for posting customizable, template based galleries, by simply uploading images to the server the script is running on. The script scans the directory you point it to (via ...

Im a bit drupal confused when it comes to float and clear I have a ...
(ie character-dependent handling) as opposed to making a span around each comma? JDigital, as I said I already know this but even J! FAQs has it http://forum.joomla.org/index.php?topic=39052.msg232066 baad mojo. ...

75 scripts from Script Stone
The script will make a FTP connection from the server it is running from. When the file is fetched from the FTP server, it will send it to the browser via the HTTP protocol. 67. PHP Based Image Watermarking Script [NEWer] This script ...

Web design seattle - 146Part IPHP: The Basics$original = More than
In other words, a well-hardened intranet server might be appropriate, but filewriting on a production Web site can be a security risk. For more information, see Chapter 29. As we explain in Chapter 30, in PHP there is now a very easy ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional