Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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?

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


Comment on Re: How to find the last date of the previous month?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (13)
As of 2014-10-20 12:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (75 votes), past polls