Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How to find the last date of the previous month?

by Athanasius (Chancellor)
on Oct 30, 2012 at 03:26 UTC ( #1001450=note: print w/replies, xml ) Need Help??


in reply to How to find the last date of the previous month?

Here is one way:

#! perl use strict; use warnings; use Date::Calc qw(Days_in_Month Today); print 'The last day of last month was ', last_day_last_month(), "\n"; sub last_day_last_month { my ($year, $month, $day) = Today([time]); if (--$month == 0) { $month = 12; --$year; } return sprintf("%02d/%d/%d", $month, Days_in_Month($year, $month), $year); }

Hope that helps,

Athanasius <°(((><contra mundum

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001450]
help
Chatterbox?
[stevieb]: I have learned that my daughter has significant brain injury, so that's affecting my decisions. Don't know who to reach out to. I just want to vent. I am honestly lost. It's something I can't code around.
[stevieb]: I am infuriated at the same time I am hopeless. It appears there are approaches to 'fix' things, but, you know..,

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2017-02-25 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (365 votes). Check out past polls.