Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Convert GMT timestamp to EST/EDT ( DateTime::Format::Strptime set_time_zone( 'America/New_York' )

by Anonymous Monk
on Jul 25, 2015 at 08:45 UTC ( [id://1136269]=note: print w/replies, xml ) Need Help??


in reply to Convert GMT timestamp to EST/EDT

#!/usr/bin/perl -- use strict; use warnings; use DateTime::Format::Strptime; my $timestamp = q{20150619-17:30:43.616}; my $fmt = DateTime::Format::Strptime->new( pattern => q{%Y%m%d-%T.%3N}, time_zone => 'UTC', ); my $dt = $fmt->parse_datetime( $timestamp ); printf "%20s %s\n", $dt->time_zone_long_name, $fmt->format_datetime( $ +dt ); $dt->set_time_zone( 'EST5EDT' ); printf "%20s %s\n", $dt->time_zone_long_name, $fmt->format_datetime( $ +dt ); $dt->set_time_zone( 'EST' ); printf "%20s %s\n", $dt->time_zone_long_name, $fmt->format_datetime( $ +dt ); $dt->set_time_zone( 'America/New_York' ); printf "%20s %s\n", $dt->time_zone_long_name, $fmt->format_datetime( $ +dt ); __END__ UTC 20150619-17:30:43.616 EST5EDT 20150619-13:30:43.616 EST 20150619-12:30:43.616 America/New_York 20150619-13:30:43.616
  • Comment on Re: Convert GMT timestamp to EST/EDT ( DateTime::Format::Strptime set_time_zone( 'America/New_York' )
  • Download Code

Replies are listed 'Best First'.
Re^2: Convert GMT timestamp to EST/EDT ( DateTime::Format::Strptime set_time_zone( 'America/New_York' )
by gtk (Acolyte) on Jul 27, 2015 at 06:13 UTC
    Thanks a lot. By the way I think DateTime::Format::Strptime module is not coming with the Perl default package.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1136269]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-16 06:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found