
cuboidgraphix
User
Feb 24, 2010, 6:30 AM
Post #4 of 11
(10490 views)
|
Re: [FishMonger] Calculate previous day given a fixed date
[In reply to]
|
Can't Post
|
|
Thanks fishmonger, I did look at a couple of those but I don't have the module loaded and I don't have the rights to install it. I did try working with epoch time and so far it works fine. The only problem I have is that I want to insert the output as a variable instead of using the printf. Any insight on how I can do this?
#!/usr/bin/perl use strict; use warnings; use Time::Local; my $date = '2010-01-01'; my $year = substr $date, 0, 4; my $month = substr $date, 5, 2; my $day = substr $date, 8, 2; my $tday = timelocal(0,0,0,$day,$month,$year); my $yday = $tday - 2716143; my($sec,$min,$hour); ($sec,$min,$hour,$day,$month,$year) = localtime($yday); # correct the date and month for humans $year = 1900 + $year; $month++; my $ydate = printf("%02d-%02d-%02d", $year, $month, $day); #print $ydate; at this point I have print $ydate commented out, but it still keeps printing it because of the printf.
|