in reply to How do you add dates to a certain user provided date?
You still face a challenge in that the year is not in ccyy format. So you need to work out is it 1904 or 2004 that you are dealing with.
Let's assume that you adddress this year problem and that based on your comment that this is not homework, look at this to convert the date from mm/dd/ccyy to epoc.
You could then take $epoc and add ($num_of_days_to_add * 86400) which is the number of seconds in a day. All that's left to do is convert this new epoc number to a valid date.$date = "03/10/2004"; my @d = split/\\/, $date; # Second, Min , Hour , Day , Month, Year $epoc = timelocal(0, 0, 0, $d[1], $d[0], $d[2]);
You can now build how you want to diaplsy your new date. Something like..($ss, $mm, $hh, $d, $mon, $yr) = localtime($epoc);
HTHprintf("NewDate: %02d/%02d/%04d\n", $mon+1, $d, $yr+1900);
|
---|