Tuesday, February 6, 2007

Print Date with Offset

#!/usr/bin/perl

use Date::Calc qw/Today Add_Delta_Days/;

$offset = -3;
@logdate = Add_Delta_Days(Today(), $offset);

$logdate[1] = sprintf("%02d", $logdate[1]);
$logdate[2] = sprintf("%02d", $logdate[2]);

print join("-",@logdate)."\n";

Code above works out on linux shell command.
To run in browser need to add header after use declaration: print "Content-type: text/html\n\n";

No comments: