#!/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

In reply to Re: Convert GMT timestamp to EST/EDT ( DateTime::Format::Strptime set_time_zone( 'America/New_York' ) by Anonymous Monk
in thread Convert GMT timestamp to EST/EDT by gtk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.