I have a script to calculate the warranty the period of one year.I add 365 days of current date.I got the correct output for the year 2007 but the 2008 year calculation getting incorrect value.please anybody explain me what is happening here.
- #!/usr/bin/perl
-
use Time::Local;
-
-
my $time=timelocal(0,0,0,21,4,2007);
-
-
my $warrenty="";
-
-
$warrenty=localtime($time+60*60*24*365);
-
-
print $warrenty;
-
-
print "\n";
-
-
$warrenty=localtime(time()+60*60*24*365);
-
-
print $warrenty;
-
The output
--------------
Tue May 20 00:00:00 2008
Thu May 21 12:29:46 2009
Regards
Rajiv
To get a future date or a previous date you can use this idea.
Use Tick count and add or subtract the number of days.
- my @temp_var = split(/ /,localtime(time() - ($day_sub*86400)));
Here $day_sub is the number of days and here i am subtracting .
To get a later date use + instead of -
Raghuram