473,382 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 4668
>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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.