in reply to How to set a processes notion of the timezone on win32?
I had a similar problem with an application that had to return local times for multiple timezones.
An easy enough way to do this is to use the DateTime module.
To convert a known time to another time, you can use:
In order to just get the current date/time in UTC format, you can use:my $oldDate = DateTime->new(month=>$monthVar, day=>$dayVar, year=>$yearVar, hour=>$hourVar, minute=>$minuteVar, time_zone=>'local'); $dateObject = $oldDate->clone()->set_time_zone('UTC'); $dateObject =~ s/T/ /; print &UnixDate($dateObject,"%m/%d/%Y %H:%M")
$dateObject = DateTime->now(time_zone=>'UTC'); print $dateObject;
|
---|
In Section
Seekers of Perl Wisdom