Hello ozboomer,

It looks that fellow Monks have already answered your question. Just for fun here is an alternative solution using Date::Manip.

#!/usr/bin/perl use strict; use warnings; use Date::Manip; use feature 'say'; sub getDate { my $tz = new Date::Manip::TZ; return $tz->convert_from_local(ParseDate(shift), 'Australia/Victor +ia'); } sub getDateFormat { my ($date, $from, $to) = @_; return UnixDate(Date_ConvTZ(ParseDate($date), $from, $to), '%d/%m/ +%Y %r'); } my @dates = ( "now", "03/18/2019 03:15:00", "03/18/2019 03:15:00 am", "03/18/2019 03:15:00 pm", ); foreach my $date (@dates) { my ( $err, $date, $offset, $isdst, $abbrev ) = getDate($date); say "Err: $err" if $err; say "Date: " . join(":", @$date); # say "@$date[2]/@$date[1]/@$date[0] @$date[3]:@$date[4]:@$date[5] +"; # say "Offset: " . join(":", @$offset); # say "Isdst: $isdst"; # say "Abbrev: $abbrev"; say getDateFormat($date,"CST", "AEDT"); } __END__ $ perl test.pl Date: 2019:4:5:2:3:8 05/04/2019 03:00:00 AM Date: 2019:3:18:13:15:0 18/03/2019 03:00:00 AM Date: 2019:3:18:13:15:0 18/03/2019 03:00:00 AM Date: 2019:3:19:1:15:0 19/03/2019 03:00:00 AM

On the solution provided above I have two different functions. One is simply converting the time from the local timezone getDate (read more Date::Manip::TZ) and the other is converting from the timezone provided to the function getDateFormat (read more for timezone Date::Manip::Zones). The first function unfortunately it returns the date already formatted so there the format is fixed. The second it returns to your desired format.

Hope this helps, BR.

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

In reply to Re: DateTime::Format::Strptime Parsing Seems to have a Problem? by thanos1983
in thread DateTime::Format::Strptime Parsing Seems to have a Problem? by ozboomer

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.