Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How to set a processes notion of the timezone on win32?

by banesong (Acolyte)
on Mar 02, 2010 at 17:46 UTC ( #826215=note: print w/ replies, xml ) Need Help??


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:

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")
In order to just get the current date/time in UTC format, you can use:
$dateObject = DateTime->now(time_zone=>'UTC'); print $dateObject;


Comment on Re: How to set a processes notion of the timezone on win32?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://826215]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-10-21 05:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (96 votes), past polls