in reply to Re: How do I find today's date?
in thread How do I find today's date?

It sure would be nice to expand this to include how to find some other simple dates:

Skip
  • Comment on Re: Answer: How do I find today's date?

Replies are listed 'Best First'.
Re^2: Answer: How do I find today's date?
by hippo (Archbishop) on Jul 16, 2025 at 12:33 UTC

    The core modules Time::Piece and Time::Seconds make this very easy.

    #!/usr/bin/env perl use strict; use warnings; use Time::Piece; use Time::Seconds; my $now = localtime; print "Today is $now\n"; my $tp = $now - ONE_DAY; print "Yesterday was $tp\n"; $tp = $now + ONE_DAY; print "Tomorrow will be $tp\n"; $tp = $now - 7 * ONE_DAY; print "A week ago was $tp\n"; $tp = $now + 7 * ONE_DAY; print "Next week will be $tp\n"; $tp = $now->add_months (-1); print "A month ago was $tp\n"; $tp = $now->add_months (1); print "Next month will be $tp\n"; $tp = $now->add_years (-1); print "A year ago was $tp\n"; $tp = $now->add_years (1); print "Next year will be $tp\n";

    🦛