Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hi,

Altering your $ENV{TZ}, for a very quick hack could do. A local $ENV{TZ} = 'EET' # EET? is a bit better.

But beware (know what you do)! This is potentially dangerous, if you use qx// or [system]() calls, require other perl scripts/use modules, do IPC (interact with other running processes), have changing configuration (see below), etc.

In a production script/environment you'll want to use a Date/Time manipulation module, like the excellent Date::Manip or Date::Calc. These will do what you need (and more), safely with regard to daylight saving times and/or configuration changes. Imagine what happens if your servers' sysop one day decides he'd switch his servers to use UTC as their RTC's timezone. These modules will return the correct date, simply adding the n hours offset will fail in such a case...

Times are just data. Operate on it. If you want to know what time it is in Zimbabwe, you'd calculate the difference to your local time -- you wouldn't reset your wristwatch (i. e. change your configuration) to see what the time would be (I hope ;)...

Hope this helps a bit,

so long,
Flexx


In reply to Re: Localtime() or gmtime() by Flexx
in thread Localtime() or gmtime() by NetStorm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-23 19:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found