Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to run a Perl script, but make it think that it is in a different timezone (GMT) than the server is configured to use normally.

I would like to do this without modify the existing script, by means of some environment variables or any configuration settings if possible.

This is for OS X and its vendor Perl (v5.12.4).

share|improve this question

1 Answer 1

up vote 6 down vote accepted

You can use the TZ environment variable ($ENV{TZ}). See http://stackoverflow.com/questions/753346/how-do-i-set-the-timezone-for-perls-localtime for more details

share|improve this answer
    
The code for GMT would be TZ=GMT perl blah.pl? –  Thilo Mar 12 '13 at 3:10
    
Pretty much. You can try it out yourself with print(scalar localtime); –  vicfn Mar 12 '13 at 3:24
1  
This was the right answer, but the community tends to frown on brief link based answers. The answer here is simple to explain, but usually it's not asking much to provide an inline example. I'm giving you the +1 anyway. –  Andrew B Mar 12 '13 at 3:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.