Hello Anonymous Monk,

Fellow Monk haukex, has already answered your question but since you mentioned the module Date::Manip here are some examples:

#!/usr/bin/perl use strict; use warnings; use Date::Manip; use feature 'say'; say "PARSING A DATE:"; my $date; say $date = ParseDate("today"); say $date = ParseDate("1st Thursday in June 1992"); say $date = ParseDate("05/10/93"); say $date = ParseDate("12:30 Dec 12th 1880"); say $date = ParseDate("8:00pm December tenth"); say ""; say "PARSING AN AMOUNT OF TIME:"; my $delta; say $delta = ParseDateDelta("in 12 hours"); say $delta = ParseDateDelta("-1:30:0"); say $delta = ParseDateDelta("4 business days later"); __END__ $ perl test.pl PARSING A DATE: 2017091300:00:00 1992060400:00:00 1993051000:00:00 1880121212:30:00 2017121020:00:00 PARSING AN AMOUNT OF TIME: 0:0:0:0:12:0:0 0:0:0:0:-1:30:0 0:0:0:4:0:0:0

You can find plenty of examples in the Date::Manip::Examples.

Update: Very nice explanation with examples of the module Date::Manip - date manipulation routines.

Update2: I think this is what you are looking for:

#!/usr/bin/perl use strict; use warnings; use Date::Manip; use feature 'say'; my $tz = new Date::Manip::TZ; my $dateLocal = ParseDate('now'); say $dateLocal; # From timeZone To timeZone my $dateTimeZone = Date_ConvTZ($dateLocal,"GMT","CST"); my $unixLocal = UnixDate($dateLocal,'%Y-%m-%d-%H-%M-%S'); say $unixLocal; my $unixTimeZone = UnixDate($dateTimeZone,'%Y-%m-%d-%H-%M-%S'); say $unixTimeZone; __END__ $ perl test.pl 2017091400:41:59 2017-09-14-00-41-59 2017-09-14-08-41-59

Relevant question convert GMT to other time zone using Date::Manip, and more information Date::Manip - Date manipulation routines.

Time zone abbreviations Time Zone Abbreviations – Worldwide List.

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: Convert GMT date and time to local time (UPDATED) by thanos1983
in thread Convert GMT date and time to local time by Anonymous Monk

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.