How to identify Daylight saving Time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpmagesh
    New Member
    • Nov 2008
    • 119

    How to identify Daylight saving Time

    Hi All,

    I am trying for something in Daylight saving time. I have a eastern time stamp and the timezone (possible timezones CST,EST,PST,MST ,HST). Basically these are two input which is required for my daylight saving time calculation.

    If the time zone is CST i have to convert the given eastern timestamp to central timestamp.
    like

    Code:
    if ($timezone == "CST")
    $central = $eastern - 3600;
    Now i have to find whether the given central timestamp ($central) is coming under the Daylight saving time or not. Can some one help me how to find daylight saving is true or false.?

    Thanks in advance,

    Thanks,
    Magesh
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    See date() manual.

    What you're looking for is the Capital "I" which return 1 if daylight saving (summer march-november) and 0 if not (winter november-march).

    So what you could do is some kind of calculation on your timezone, such as:

    Code:
    $cental = $eastern - 3600 + (date('I') * 3600);
    if date('I') returns zero, then 0*3600=0 basically adding nothing. If it is daylight savings time, then you add one more hour. IF $eastern is not already in daylight savings time.

    Eastern standard time (EST) always equals central daylight time (CDT), in the math above:

    $CDT = $EST - 3600 + 3600;
    $CDT = $EST + 0;

    Hope that helped,


    Dan

    Comment

    Working...