473,385 Members | 1,372 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,385 software developers and data experts.

Daylight Savings Time Question

Hi, the server that hosts my PHP pages has its clock set to Greenwich
Mean Time (GMT timezone 0). I need for my PHP scripts to have access
to my local time which is Central Standard Time in the U.S. (CST
timezone -6). Note: daylight savings time _is_ observed in my state. I
have looked all over a PHP algorithm that would convert GMT to CST but
have so far not been successful. Does anyone have such an algorithm
lying around that they could post?

Thanks in advance.

Karl

Mar 7 '07 #1
6 5133
dredge wrote:
Hi, the server that hosts my PHP pages has its clock set to Greenwich
Mean Time (GMT timezone 0). I need for my PHP scripts to have access
to my local time which is Central Standard Time in the U.S. (CST
timezone -6).
Just RTFM:

php.net/date_default_timezone_set

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

http://acm.asoc.fi.upm.es/~mr/ ; http://acm.asoc.fi.upm.es/~ivan/
MSN:i_*************************@hotmail.com
Jabber:iv*********@jabber.org ; iv*********@kdetalk.net
Mar 7 '07 #2
On Mar 7, 9:14 am, Iván Sánchez Ortega <ivansanchez-...@rroba-
escomposlinux.-.punto.-.orgwrote:
dredge wrote:
Hi, the server that hosts my PHP pages has its clock set to Greenwich
Mean Time (GMT timezone 0). I need for my PHP scripts to have access
to my local time which is Central Standard Time in the U.S. (CST
timezone -6).

Just RTFM:

php.net/date_default_timezone_set

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

http://acm.asoc.fi.upm.es/~mr/;http:....upm.es/~ivan/
MSN:i_eat_s_p_a_m_for_breakf...@hotmail.com
Jabber:ivansanc...@jabber.org ; ivansanc...@kdetalk.net
Woops, forgot to include that the server is running PHP 4.3.11 I
believe the date_default_timezone_set function is only available in
versions 5+

Mar 7 '07 #3
dredge wrote:
Woops, forgot to include that the server is running PHP 4.3.11 I
believe the date_default_timezone_set function is only available in
versions 5+
You're right. I'd suggest you to upgrade to a PHP5 webserver.

On the other hand, you can always use time() to get the current timestamp,
at GMT+0, and manually substract 6 hours.

You may also try the time/date functions that format dates - even if the
internal clock is set at GMT (and it's a good idea to rely on GMT, believe
me), if the server is already well configured, you don't have any need to
manually set the timezone - the environment does that.

By the way: please use GMT+0 (or unix timestamps) to keep dates on a
database. If your country follows DST and you use the local date, you may
run into lots of problems.

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

http://acm.asoc.fi.upm.es/~mr/
Proudly running Debian Linux with 2.6.17-1-amd64-k8 kernel, KDE3.5.3, and
PHP 5.2.0-8 generating this signature.
Uptime: 17:22:08 up 14 days, 22:23, 1 user, load average: 0.65, 0.41, 0.40

Mar 7 '07 #4
Iván Sánchez Ortega wrote:
By the way: please use GMT+0 (or unix timestamps) to keep dates on a
database. If your country follows DST and you use the local date, you may
run into lots of problems.
Not just "may" - it's a slam-dunk!

Microsoft is announcing this week that you WILL run into
problems on their systems... as are several other companies.

In 2005, the Republican congress decided to mess with DST in
order to trick some particularly foolish voters into believing
that it will save energy dollars.

As a result, for the next few months, most software written
prior to 2005, and all hardware with DST algorithms in them, and
which were built prior to 2005 will be messed up during these
months.

Mar 7 '07 #5
>By the way: please use GMT+0 (or unix timestamps) to keep dates on a
>database. If your country follows DST and you use the local date, you may
run into lots of problems.

Not just "may" - it's a slam-dunk!
Maybe, maybe not. It depends on what you're using the time stamps
for. And *future* times are a problem, since your conversion from
human local time units to UTC may turn out to be inaccurate if
governments screw things up. I'll agree that having the OS clock
in UTC is a good idea. (Let's see, we'll count heartbeats while 1
minute goes by, starting at Sunday, 1:59:30 Mar 11, 2007. Wait!
This guy's pulse rate is 3600! Yikes!)

If I've got a clock that counts seconds and is expected to be accurate
for the next 50 years, you'll need to fiddle with the display algorithm
however many times governments screw with daylight savings time. This
corresponds to the OS daylight savings time patches.

If I'm a stay-at-home type of guy (don't change time zones much)
if I've got an appointment calendar with a lunch appointment every
Monday at noon, chances are much better the program will do what I
mean if it stores that future appointment in local time. Chances are I
mean the appointment is at noon, local time, regardless of whether
it's a multiple of 7*24 hours since the last appointment. I might
even mean noon, whatever local time zone I am in at the moment.
This corresponds to the Microsoft Exchange Server and Outlook daylight
savings time patches.

If I do change time zones a lot, I probably want to record the time zone
of the locality to which the appointment applies. Few users who need
this ability will really use it to advantage until they get burned.
And what, exactly, is the "locality" of a phone conference with members
in several time zones?
>Microsoft is announcing this week that you WILL run into
problems on their systems... as are several other companies.

In 2005, the Republican congress decided to mess with DST in
order to trick some particularly foolish voters into believing
that it will save energy dollars.
Has anyone come up with proof that this will save more energy than
changing DST in the *other* direction? Most of the offered
explanations (mostly by news media) involve DST actually changing
the number of hours the sun is shining.

Mar 8 '07 #6
Gordon Burditt wrote:
Let's see, we'll count heartbeats while 1 minute goes by, starting at
Sunday, 1:59:30 Mar 11, 2007. Wait! This guy's pulse rate is 3600!
Yikes!
That would only happen in the autumn. In spring, the parient would be
observed to have, say, 60 heartbeats over a period of 61 minutes.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Mar 8 '07 #7

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

Similar topics

1
by: Marcus | last post by:
Hi all, sorry to post yet another unix timestamp question, but I've been looking through php.net and google and can't find exactly what i need... plus I think my brain has shut down from too many...
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...
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: 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: 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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have 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...

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.