Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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

Comment on Re: How to get last day of 2 months ago
Select or Download Code

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 browsing the Monastery: (2)
As of 2015-10-10 20:23 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (258 votes), past polls