in reply to Getting previous dates from the current date

DateTime is also very good. That, combined with the two mentioned above, are the three "standard" datetime modules in Perl. Each has its proponents and many of us will use more than one, depending on the project.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

  • Comment on Re: Getting previous dates from the current date

Replies are listed 'Best First'.
Re^2: Getting previous dates from the current date
by Smylers (Pilgrim) on Mar 29, 2005 at 17:01 UTC
    DateTime is also very good.

    I agree; the DateTime suite is excellent: it has a very well-thought-out interface, does pretty much anything that any of the other modules do, and correctly covers all the awkward corners of date- and time-handling that you don't want to think about.

    This thread has a bunch of different responses, but none of them look to me anywhere near as simple as:

    print DateTime->now->subtract(days => 7)->date

    Update: And, after actually bothering to read the other suggestions (rather than just noticing how complicated they look), the hand-rolled ones (avoiding modules for the date arithmetic) all seem to be wrong as well. So that's another advantage of DateTime: it quietly gets correct things that you haven't even bothered to think about.

    Smylers