http://qs321.pair.com?node_id=335379


in reply to How do you add dates to a certain user provided date?

I like the idea of converting to epoc time. And you can do this with core the Time::Local module.

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.

$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 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.

($ss, $mm, $hh, $d, $mon, $yr) = localtime($epoc);
You can now build how you want to diaplsy your new date. Something like..
printf("NewDate: %02d/%02d/%04d\n", $mon+1, $d, $yr+1900);
HTH
-----
Of all the things I've lost in my life, its my mind I miss the most.