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");
...
...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.