in reply to How to convert time from one time zone to another
You can just set the TZ environment variable to the timezone you want, and use localtime:
The last time I ran it, this printed{ local $ENV{TZ} = "EST+05"; print "In New York, it is ".localtime()."\n"; } { local $ENV{TZ} = "IST-05:30"; print "In Mumbai, it is ".localtime()."\n" }
I think this will work on Windows as well as Unix, but I don't have a Windows box to test it on.In New York, it is Mon Dec 19 14:25:01 2005 In Mumbai, it is Tue Dec 20 00:55:01 2005
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to convert time from one time zone to another
by Celada (Monk) on Dec 19, 2005 at 21:32 UTC | |
by robin (Chaplain) on Dec 19, 2005 at 21:51 UTC | |
by ww (Archbishop) on Apr 02, 2012 at 15:12 UTC |
In Section
Seekers of Perl Wisdom