December 10, 2023, 09:51:26 PM

Author Topic: How to get local time using PERL?  (Read 12712 times)

0 Members and 1 Guest are viewing this topic.

pzqwpo

  • Guest
How to get local time using PERL?
« on: May 07, 2009, 08:35:02 PM »
How to get local time using PERL while the server I am using is in a different time zone? For example, my local time is 9 am August 17th. But the server is in 9pm August 16th time zone. How do I write PERL code to get my local time?

Offline benthehutt

  • Global Moderator
  • Seasoned Poster
  • *****
  • Posts: 368
  • Country:
  • "Drugs? You'd better not be!" - my mom
    • Echelon9
Re: How to get local time using PERL?
« Reply #1 on: May 08, 2009, 11:59:18 AM »
The easiest way is to use gmtime, which returns Greenwich mean time, i.e. with no daylight savings. Then go to http://wwp.greenwichmeantime.com/ and select your nation. It will tell you the difference between your time and Greenwich mean time. You just add the correct amount of hours and you're good to go.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.