Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Month Dates

by siva kumar (Pilgrim)
on Mar 02, 2007 at 06:47 UTC ( [id://602834]=note: print w/replies, xml ) Need Help??


in reply to Month Dates

You can use "inc_month" function in "DateTime::Precise" module.
use DateTime::Precise; use strict; my $t1 = DateTime::Precise->new; my %months = ( 1 => q{January}, 2 => q{February}, 3 => q{March}, 4 => q{April}, 5 => q{May}, 6 => q{June}, 7 => q{July}, 8 => q{Auguest}, 9 => q{Septemper}, 10 => q{October}, 11 => q{November}, 12 => q{December}, ); my $thisMonth = $months{$t1->month}; my $prevMonth = $months{$t1->inc_month(-1)->month}; my $t1 = DateTime::Precise->new; my $monthB4rLast = $months{$t1->inc_month(-2)->month}; my $t1 = DateTime::Precise->new; my $monthB4rLast1 = $months{$t1->inc_month(-3)->month}; print "This Month is $thisMonth\n"; print "Previous Month is $prevMonth\n"; print "Month before last is $monthB4rLast\n"; print "Month before 2 months is $monthB4rLast1\n"; Output: ------- ThisMonth is March Next Month is February Month before last is January Month before 2 months is December

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-29 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found