Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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"); ... ...


Comment on Re: date
Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2014-07-12 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (237 votes), past polls