Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: date

by ryan (Pilgrim)
on May 29, 2001 at 06:37 UTC ( #83821=note: print w/replies, xml ) Need Help??

in reply to Yesterday's or last month's date?

I have become quite happy with the Date::Manip library after reading the Perl Cookbook. I have found it slow for repetitive parsing, but it can make things very easy if you are constatly wanting odd dates using todays date as a basis.

ParseDate can take an 'english like' string and then output that date in its own format of YYYYMMDDHH:MM:SS

UnixDate is another function that converts ParseDate's output to a customisable format, similar to localtime as shown above, it lets you output things in a more customisable format if that is of any concern.

use Date::Manip qw(ParseDate UnixDate); #examples giving epoch seconds $date = ParseDate("last month"); $date = ParseDate("yesterday"); $date = ParseDate("250 days ago"); $date = ParseDate("2nd tuesday in april"); #date formating example $date = UnixDate($date, "%d-%m-%Y"); ... ...

Replies are listed 'Best First'.
Re: Re: date
by myocom (Deacon) on May 29, 2001 at 06:45 UTC

    Indeed, Date::Manip's ParseDate allows for a lot of flexibility. Here is an example of how I used ParseDate to create a very handy "sleep until" script.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2022-01-20 00:02 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (56 votes). Check out past polls.