in reply to Re: Convert GMT timestamp to EST/EDT (Time::Local)
in thread Convert GMT timestamp to EST/EDT

:) Time::Piece in perls v5.9.5-v5.23.1
## @nn = localtime( timegm( reverse @nn ) ); ##$nn[4]++; # Make month 1-based (ugh) ##$nn[5] += 1900; # (ugh) ##$stamp = sprintf "%d%02d%02d-%02d:%02d:%02d%s", use Time::Piece qw/ localtime ; $stamp = localtime( timegm( reverse @nn ) )->strptime('%Y%m%d-%H:%M:% +S').$f;
  • Comment on Re^2: Convert GMT timestamp to EST/EDT (Time::Local + Time::Piece)
  • Download Code

Replies are listed 'Best First'.
Re^3: Convert GMT timestamp to EST/EDT (Time::Local + Time::Piece)
by ikegami (Patriarch) on Jul 28, 2015 at 18:39 UTC
    This only works if your local time zone happens to be EST/EDT.

      The title of the thread is "Convert GMT timestamp to EST/EDT." :P

        Right, but the code posted anonymously converts to local time instead. That may not be correct.

        On second thought, he surely meant for $ENV{TZ} = "US/Eastern"; to remain used, in which case his code works. I didn't quite understand his point (that you can make things more complicated by replacing sprintf with Time::Piece) when I wrote my comment. If you want to use strftime instead of sprintf, you might as well grab it directly from POSIX instead of involving (rather horrible) Time::Piece.

Re^3: Convert GMT timestamp to EST/EDT (Time::Local + Time::Piece)
by jellisii2 (Hermit) on Jul 27, 2015 at 13:27 UTC
    "The more you know!" *stars* --edit wow.. rough crowd.