sannag has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|