solarisfire has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, newbie to Perl and have a little bit of a problem, but should be quite simple to work out for someone more experienced. I have a small script to work out the date last month and the year last month that looks like this:
#!/usr/bin/perl use DateTime; $dt = DateTime->now(); $month = $dt->subtract(months => 1)->strftime("%m"); $year = $dt->subtract(months => 1)->year(); print $dt."\n"; print $month."\n"; print $year."\n";
System date at time of writing is: Tue Feb 7 14:47:55 GMT 2012 which should give me a month of 01, and a year of 2012 right? So why is the output: 2011-12-07T14:47:55 01 2011 :(
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Datetime Problem - Wrong Time
by chessgui (Scribe) on Feb 07, 2012 at 15:07 UTC | |
by solarisfire (Novice) on Feb 07, 2012 at 15:10 UTC | |
by tobyink (Canon) on Feb 07, 2012 at 23:03 UTC | |
|
Re: Datetime Problem - Wrong Time
by Anonymous Monk on Feb 07, 2012 at 14:59 UTC | |
by Anonymous Monk on Feb 07, 2012 at 15:01 UTC |