Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How to subtract month without using module?

by ikegami (Patriarch)
on Jul 25, 2005 at 06:44 UTC ( [id://477705]=note: print w/replies, xml ) Need Help??


in reply to How to subtract month without using module?

Are you allowed using the modules that come with Perl? If so, the safest way is:
use Time::Local qw( timelocal_nocheck ); my ($day, $month, $year); my $now = time; ($day, $month, $year) = (localtime($now))[3, 4, 5]; $month -= 6; my $new_time = timelocal_nocheck(0, 0, 0, ,$day, $month, $year); ($day, $month, $year) = (localtime($new_time))[3, 4, 5]; printf("%04d-%02d-%02d\n", $year, $month, $day);

Log In?
Username:
Password:

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

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

    No recent polls found