LPM: Test / question on date stuff

Rich Bowen rbowen at rcbowen.com
Wed Feb 9 09:45:15 CST 2000


Carl Rose wrote:
> 
...
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
> = localtime(time);
>     $mon += 1;
>     $year = $year +1900;
> 
>    print "$mon/$mday/$year \n";
> 
> It of course returns the date just like I want it
> (02/09/2000).  So what code do I issue to get 28 days
> from now added onto the day and get the correct
> rollaround. (ie when you add 28 above you get Feb 37th
> -ugg instead of the early part of March).  Any help
> would be appreciated and go toward good karma.

How about:

$now = time;
$later = $now + (28 * 24 * 60 * 60);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
  = localtime($later);
    $mon += 1;
    $year = $year +1900;
print "$mon/$mday/$year \n";

Enjoy, and welcome to the list.

Rich
-- 
http://www.ApacheUnleashed.com/
Lexington Perl Mongers - http://lexington.pm.org/
PGP Key - http://www.rcbowen.com/pgp.txt



More information about the Lexington-pm mailing list