That's fine until you get to the first day of the month:
$ perl -l
use strict;
use warnings;
my $db_name="2007_12_01_04_49_15";
my @date=split /_/,$db_name;
$date[2]=$date[2]-1;
$db_name=join '_',@date;
print $db_name;
__END__
2007_12_0_04_49_15
Date and time calculations (e.g. month changes, leap years, timezones) are surprisingly difficult to get right. Don't reinvent the wheel. Use an existing module from .
| [reply] [Watch: Dir/Any] [d/l] |
Errr ... what happens when it is the first of the month? Perhaps you'd be better off looking at the timelocal function of Time::Local and localtime, converting to an epoch value, decrementing by 86400 then converting back.Cheers, JohnGG | [reply] [Watch: Dir/Any] [d/l] |
narainhere,
What will happen if the day is 1st day of any month?
So you have to check the condition for month and year also.
| [reply] [Watch: Dir/Any] |