Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Date::Manip and date

by SBECK (Chaplain)
on Jul 09, 2015 at 17:53 UTC ( [id://1134002]=note: print w/replies, xml ) Need Help??


in reply to Re: Date::Manip and date
in thread Date::Manip and date

Or you can continue to use Date::Manip. The exact equivalent of the DateTime script is:
use Date::Manip::Date; my $date = new Date::Manip::Date; $date->parse('1988-12-13'); print $date->printf('%O -> %s');
and Date::Manip handles all time zones just like the DateTime modules.

Replies are listed 'Best First'.
Re^3: Date::Manip and date
by zwon (Abbot) on Jul 09, 2015 at 22:21 UTC
    Minor correction. It's not exact, in case of DateTime it's 1988-12-13T00:00:00 UTC, and in case of Date::Manip it's local time. It should be:
    $date->parse('1988-12-13 UTC');
    I wonder if it is possible to pass time zone separately from the date.

      Date::Manip always parses dates in the local time zone (unless of course there is a zone attached to the date string), so you're right that my script wasn't exact. My apologies.

      If you want to parse dates in UTC by default, use:

      use Date::Manip::Date; my $date = new Date::Manip::Date; $date->config("setdate","now,UTC"); $date->parse('1988-12-13'); print $date->printf('%O -> %s');
      and that gives the same result as the DateTime script.

Log In?
Username:
Password:

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

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

    No recent polls found