E
Edward
Hi all,
The below script works fine for all dates (change the value in $time),
except if the date is the 2nd of the month.
Given a date of 02/09/04 the script returns the date 32/08/04.
It's kind of the correct result in terms of number of days/months, but
should obviously read 01/09/04!
Anyone know how I can fix it??
Thanks,
Edward.
#!/path/to/perl
use POSIX;
$time="01/09/04";
my ($d, $m, $y) = split ('/', $time);
my $s = mktime (0, 0, 0, $d - 1, $m - 1, $y - 1900);
($d, $m, $y) = (localtime($s - 86400))[3..5];
$time = sprintf ('%02d/%02d/%04d', $d + 1, $m + 1, $y + 1900);
print "$time\n";
The below script works fine for all dates (change the value in $time),
except if the date is the 2nd of the month.
Given a date of 02/09/04 the script returns the date 32/08/04.
It's kind of the correct result in terms of number of days/months, but
should obviously read 01/09/04!
Anyone know how I can fix it??
Thanks,
Edward.
#!/path/to/perl
use POSIX;
$time="01/09/04";
my ($d, $m, $y) = split ('/', $time);
my $s = mktime (0, 0, 0, $d - 1, $m - 1, $y - 1900);
($d, $m, $y) = (localtime($s - 86400))[3..5];
$time = sprintf ('%02d/%02d/%04d', $d + 1, $m + 1, $y + 1900);
print "$time\n";