473,473 Members | 1,415 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Daylight Savings Time

I've got a newb question about Daylight Savings Time (DST). First of
all here is some server info:

Apache 1.3.28
PHP 4.3.6
MySQL 3.23.49
Time is set to GMT

My goal is to be able to accurately record website visits according to
my local time (U.S. Central) every day of the year, no matter if I am
in DST or not. I need a full datetime set of information (hour, min,
second, etc).

I have devised this line of code...

$date=date("Y:m:dH:i:s",time-18000);

....but it does not help me when DST changes for me, as GMT does not
observe DST.

Next I tried this:

echo("server time is: " . date("H:i:s") . "<br>\n");
putenv("TZ=US/Central");
echo("new server time is: " . date("H:i:s") . "<br>\n");

And got these results:

server time is: 17:46:44
new server time is: 17:46:44

Apparently, the server does not allow me to change my timezone to
Central time (because the resulting times are the same). The
application I am developing relies heavily on *accurate* time
information. Anyone have any ideas how I can get this DST issue
figured out?
Jul 17 '05 #1
1 4673
>I've got a newb question about Daylight Savings Time (DST). First of
all here is some server info:

Apache 1.3.28
PHP 4.3.6
MySQL 3.23.49
Time is set to GMT

My goal is to be able to accurately record website visits according to
my local time (U.S. Central) every day of the year, no matter if I am
in DST or not. I need a full datetime set of information (hour, min,
second, etc).
Then you *ALSO* need to be able to record whether or not DST was in
effect at the time or not. Otherwise, there will be two GMT timestamps
that translate to the SAME Central timestamp (one CST, one CDT, and
that's the only thing different about them).
I have devised this line of code...

$date=date("Y:m:dH:i:s",time-18000);

...but it does not help me when DST changes for me, as GMT does not
observe DST.
Have you tried it? UNIX time stamps are stored in GMT. The presentation
of the time information is handled when you convert it to printable form.

Next I tried this:

echo("server time is: " . date("H:i:s") . "<br>\n");
putenv("TZ=US/Central");
echo("new server time is: " . date("H:i:s") . "<br>\n");

And got these results:

server time is: 17:46:44
new server time is: 17:46:44

Apparently, the server does not allow me to change my timezone to
Central time (because the resulting times are the same). The
I recommend that you also print the time zone in the above example.
I doubt it has changed. I don't see any doc that says you can
change the output of date() by changing TZ with putenv(), and worse,
I don't see any doc that says that changing TZ with putenv() will
not affect threads other than yours (for example, the Apache server
logs) for longer than your script runs.

There is some evidence on the PHP site in the commented version of
the putenv function page that it does, on at least one implementation,
affect the Apache logs when you change TZ. There is also a suggestion
that if you invoke mktime(0,0,0,1,1,1970) after doing a putenv()
on the TZ environment variable, the change will take for your
program. I have not tested this.

In the C world, I think there are some implementations where once
you call localtime(), changing TZ further will not change the time
zone localtime() returns unless you call some other function not
available in PHP (tzset()).
application I am developing relies heavily on *accurate* time
information. Anyone have any ideas how I can get this DST issue
figured out?


If you really want accurate time information, I suggest storing it
in GMT.

Gordon L. Burditt
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bathroom_Monkey | last post by:
For posterity's sake, here is an algorithm I created to take a GMT time and convert it to U.S. central time, accounting for daylight saving time. Note: this algorithm can be modified to work for...
2
by: hourang | last post by:
ok im getting tired of looking for an answer and coming up short with scripts that dont work. i have a application that uses GMT for all its times and needs the clients timeoffset for showing the...
1
by: Ernie | last post by:
I am creating an .ics file that when opened (via Outlook) inserts a meeting into the calendar. All works fine unless the date and time I'm inserting happens to occur on the hour the time changes...
10
by: Marc Pelletier | last post by:
Hello, I am writing an application that does some simple astronomical calculations. One of the variables I need is the number of hours passed in this year. I've written the following function ...
3
by: chrisdevey | last post by:
Is there any way to make a System.Timers.Timer adjust for daylight savings time change? In a long running process I set a timer as follows for a daily expiration: _myTimer = new...
3
by: Anna | last post by:
Hi, I've already found out that .Net Framework 1.1 does not properly handle anything that is related to a non-current timezone. Since my project should be released before the release of...
3
by: mmuras | last post by:
I did not see any discussions / threads for this but if there is one please let me know: -First, I am one of only two individuals within my company's IT Dept. -We have a Windows Server 2003 R2...
4
by: Polaris431 | last post by:
I have a web application in ASP.NET that will be used globally. Data is collected on mobile devices running Windows Mobile and sent to the web server where it is stored and can be viewed. Data is...
3
by: Generic Usenet Account | last post by:
Hi, Is there any way to make time-of-day adjustments for daylight savings using only standard time functions? We have a program that executes daily at a fixed time of day. After daylight...
27
by: RobG | last post by:
I was investigating a function to determine whether daylight saving was being observed on a particular date (given the platform's regional settings) and came across a suggestion at merlyn.com to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.