Despite that you're asking for "without using new additional Perl Libraries", I'd suggest using the Date-Manip library.

There's one complication. Date-Manip won't handle the fractional seconds for you, other than ignoring it when parsing a date. If you don't need to keep the fractional seconds, then this should work:

use warnings; use 5.016; use Date::Manip::Date; my$db = Date:: Manip::Date->new(undef, ["setdate" => "now,utc"]); # parse as UTC date +s while (<>) { chomp; my($datestr, $count) = split /,/; my$d = $db->new; if (my $e = $d->parse($datestr)) { warn qq(cannot parse date: $datestr); } else { $d->convert("America/New_York"); say $d->printf("%Y%m%d-%H:%M:%S %Z"); # print in similar forma +t, but with timezone name } }

If you also have to handle the fractional seconds, then either use a different module that handles them, or copy the fractional seconds by hand, like this.

use warnings; use 5.016; use Date::Manip::Date; my$db = Date::Manip::Date->new(undef, [q(setdate) => q(now,utc)]); while (<>) { /^([-0-9:]{17})(\.[0-9]{3}),(.*)/ or die qq(cannot parse input lin +e); my($datestr, $frac, $count) = ($1, $2, $3); my$d = $db->new; if (my $e = $d->parse($datestr)) { warn qq(cannot parse date: $datestr); } else { $d->convert(q(America/New_York)); say $d->printf(q(%Y%m%d-%H:%M:%S)) . $frac . $d->printf(q( %Z) +); } }

Output from the latter code follows.

20150619-13:30:43.616 EDT 20150619-13:30:33.442 EDT 20150619-13:30:40.376 EDT 20150619-13:30:38.863 EDT 20150619-13:30:56.936 EDT 20150619-13:30:34.952 EDT 20150619-13:30:45.889 EDT 20150619-13:30:53.940 EDT 20150619-13:30:51.154 EDT 20150619-13:30:48.699 EDT

Update: for similar questions, see also GMT to PST format


In reply to Re: Convert GMT timestamp to EST/EDT by ambrus
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.