in reply to How to find the last date of the previous month?
Steps:
1. Find the epoch at 00.00 hrs for Date 1 of current month, current year.
2. Subtract 1 from that to reach previous day and convert that epoch again into date.
3. Grab the date and/or month value from it.
#!/usr/bin/perl -w use strict; use Class::Date; my $date = new Class::Date [`date +%Y`, `date +%m`, 1, 0, 0, 0]; my $curMonthEpoch = $date->epoch; my $prevMonthEpoch = $curMonthEpoch - 1; print "Last Date of Prev Month=".`date --date='\@$prevMonthEpoch' +%d` +;
|
|---|