in reply to DateTime Daylight savings question

use DateTime; use DateTime::TimeZone; my $dt = DateTime->now; # same as ( epoch => time() ) print( $dt->hms, "\n" ); $dt->set_time_zone( 'America/New_York' ); print( $dt->hms, "\n" ); $dt->set_time_zone( 'EST' ); print( $dt->hms, "\n" );
21:10:32 17:10:32 16:10:32

Works for me. WinXP, ActivePerl 5.8.8, DateTime 0.36, DateTime::TimeZone 0.63

Replies are listed 'Best First'.
Re^2: DateTime Daylight savings question
by jsilva_im (Novice) on Sep 19, 2008 at 21:19 UTC
    Interesting...Here are my results that I ran at: 15:22 PM EDT
    22:22:34 18:22:34 17:22:34
    Seems to work for me. My question might be because of a misunderstanding with TimeZone, but why is 'EST' and America/New_York any different? Isn't 'EST' incorrect anyway since we are currently still in DST? Thanks for all of your suggestions everyone! Specially on a Friday!

      Here are my results that I ran at: 15:22 PM EDT

      Since you replied at 17:19 PM EDT,
      I think you meant to say 17:22 PM EDT, and
      I think the time was really 17:18 PM EDT or earlier.

      Seems to work for me.

      Uh no, all three times are off by one hour (and four minutes).
      Your system's clock is wrong,
      your system's time settings are wrong, or
      your system's time zone info is wrong.

      why is 'EST' and America/New_York any different?

      America/New_York is currently equivalent to EDT.
      In a couple of months, America/New_York will be equivalent to EST.

      Isn't 'EST' incorrect anyway since we are currently still in DST?

      Not incorrect. It's simply a different time zone. There would be problem if America/New_York and EST returned the same time for the current value of now.