Solved

How can I update the timezone based on US DST ?

Posted on 2015-01-22
6
80 Views
Last Modified: 2015-01-27
I have a website with US timezone maintained in "America/Los Angels" located server.   My server timezone is set as GMT.   I have a table called "time zones" with GMT hour + seconds difference.  

I am calculating the time based user (he will be from US region) timezone with my "time zones" table and display it.  Every user will have it is own timezone to calculate all the time display. I am fine this with my timezone table.

My client says I need to consider "Daylight Savings Time" along with my table and above structure.  How  can I find out the daylight saving time all the time in a year and update the timezone OR calculate as per the above scenario ?

I googled and could not find how to do exactly.  Can anyone help me?
0
Comment
Question by:Loganathan Natarajan
  • 2
  • 2
  • 2
6 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 40564958
The timezone tables take DST into account, you don't need to.  And just putting in an offset won't get DST for you because DST is based on local law and not the offset from GMT.  Arizona for example, does not use DST even though the states around it do.

http://php.net/manual/en/timezones.php
http://php.net/manual/en/function.date-default-timezone-set.php
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 40565509
This article tells how to handle Date/Time in PHP.  I believe the article covers these points, as well as issues related to getting the client time from their browser, etc.

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 40572082
@ Dave Baldwin  The timezone tables take DST into account, you don't need to.

Check the attachment table structure as " timezone tables" ?  Is this OK?

Then How can I know about DST and add the difference hours into the timezone ?  Just clarify.
timezone-1.png
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
ID: 40572315
No, that is not likely to work.  Time zones are not just offsets from GMT but a set of rules telling how to calculate the proper offset on any given date.  This site http://www.worldtimezone.com/ has maps for time zones.  You can see there that offset from GMT is not strictly observed.  Local law is the deciding factor.
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 40572432
How can I know about DST and add the difference hours into the timezone ?
1. You can know about DST by checking the value of date('I').  This is shown in the article linked above, and documented in the PHP.net web site.
http://php.net/manual/en/function.date.php

2. You do not have to add the difference - the response from date() based on the settings of date_default_timezone_set() will give you the correct local time.  There is a large, open-source community that contributes to the underlying data model of the PHP language, and they are almost certainly correct about the issues of time zones and local laws and customs in any locale around the world.  Better to rely on them than try to do this all yourself!
0
 
LVL 36

Author Closing Comment

by:Loganathan Natarajan
ID: 40572481
Thanks experts. I understand now and I will handle it based on the Timezone.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now