Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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

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


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-20 16:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found