Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: How to get last day of 2 months ago

by Anonymous Monk
on Mar 11, 2011 at 17:01 UTC ( #892698=note: print w/replies, xml ) Need Help??

in reply to How to get last day of 2 months ago

#!/usr/bin/perl use strict; use warnings; use 5.012; use Time::Local qw( timegm_nocheck ); my ($y, $m, $d) = (localtime)[5,4,3]; my $start = scalar gmtime(timegm_nocheck(0,0,0, (1-1), $m-1, $y)); my $end = scalar gmtime(timegm_nocheck(0,0,0, (1-1), $m, $y)); say "Today is " . localtime; say join "\n", $start, $end;
** prints
Today is Fri Mar 11 11:56:50 2011 Mon Jan 31 00:00:00 2011 Mon Feb 28 00:00:00 2011

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (15)
As of 2016-10-26 13:57 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (341 votes). Check out past polls.