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

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

by Anonymous Monk
on Oct 30, 2012 at 10:44 UTC ( #1001483=note: print w/replies, xml ) Need Help??

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


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` +;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001483]
and the voices are still...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2017-07-23 15:34 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (347 votes). Check out past polls.