?
Solved

How can I update the timezone based on US DST ?

Posted on 2015-01-22
6
Medium Priority
?
118 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 1000 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 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
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 1000 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

719 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