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

Re: How to get last month date period

by youlose (Scribe)
on Mar 04, 2010 at 18:32 UTC ( #826777=note: print w/ replies, xml ) Need Help??


in reply to How to get last month date period

use DateTime;
use Modern::Perl;
my $fdm = DateTime->now->subtract(months=>1)->truncate(to=>'month');
my $ldm = DateTime->last_day_of_month(year=>$fdm->year,month=>$fdm->month);
my $stf_pat = '%d %b %Y';
say $fdm->strftime($stf_pat),' - ',$ldm->strftime($stf_pat);


Comment on Re: How to get last month date period
Replies are listed 'Best First'.
Re^2: How to get last month date period
by kivilahtio (Initiate) on Dec 22, 2014 at 09:51 UTC
    Sweet! A beautiful solution.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2015-08-05 09:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (80 votes), past polls