in reply to Re: Last month's number with Time::Piece
in thread Last month's number with Time::Piece
use warnings; use strict; use Time::Piece; my $t = Time::Piece->new(); my $year = $t->year; my $last_month = $t->add_months(-1)->mon; # Pass the last month and year to a new Time::Piece object my $t_last_month = Time::Piece->strptime("$last_month$year", "%m%Y"); # Now use Time::Piece month_last_day to get it my $last_day_of_month = $t_last_month->month_last_day; print "Last Month = $last_month - It's last day = $last_day_of_month \ +n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Last month's number with Time::Piece
by Anonymous Monk on Dec 05, 2014 at 14:20 UTC |