Greetings! I am running in to invalid date time problem and require your advice/help. I am reading a file which has date and time in PST (America/Los_Angeles). I am converting it to UTC I encounter an error when run the time 03/113/2016 00:02:00. 13th March 2016 2Am is daylight saving.

use DateTime; $occuranceTime = "00:02:00"; $occuranceDate = "03/13/2016"; my $recordYear = substr ($occuranceDate, 6,4); my $recordMonth = substr ($occuranceDate, 0,2); my $recordDate = substr ($occuranceDate, 3,2); my $recordSec = substr ($occuranceTime, 0,2); my $recordHour = substr ($occuranceTime, 3,2); my $recordMin = substr ($occuranceTime, 6,2); my $recordOnPST =DateTime->new( year => $recordYear, month => $rec +ordMonth, day => $recordDate, hour => $recordHour, minute => $recordMin +, second => $recordSec, time_zone => 'America/Los_Angeles'); #my $recordOnPST =DateTime->new( year => $recordYear, month => +$recordMonth, day => $recordDate, # hour => $recordHour, minute => $recordMi +n, second => $recordSec, time_zone => 'floating'); my $recordOnUTC = $recordOnPST ->set_time_zone('UTC'); print "$recordOnPST \n"; print "$recordOnUTC \n";

I did try to use time zone as floating (which is UTC) but had no success (I mean I need to time first in PST before I convert to UTC) Thank in advance for all your assistance


In reply to DateTime Invalid local time for date in time zone by sannag

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.