Solved

How can I update the timezone based on US DST ?

Posted on 2015-01-22
6
107 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 83

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 110

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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
LVL 83

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 110

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

729 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