PHP Date Project

My programming project calls for a user to input their birthday then we have to validate the date. If it is not valid we send an error message, but if it is we have to offset it by adding seven days to the given date.
This is what I have so far:

<?php $date_format = 'Y-m-d'; $month='05'; $day='03'; $year='1999'; $input = '$month-$day-$year'; $input = trim($input); $time = strtotime($input); $is_valid = checkdate($month,$day,$year) == $input; print "Your birthdate is ".($is_valid ? 'valid' : 'invalid'); print "
"; print "
"; ?>

The numbers I put in will be replaced by POST which will be linked to an HTML page.
I am just lost on how to add the seven days to the date given! I figured out how to add seven days to today’s date but not what the assignment calls for.

Thanks for the help,
Courtney

Try this:

[php]<?php

$date_format = ‘Y-m-d’;
$month=‘05’;
$day=‘03’;
$year=‘1999’;
$input = ‘$month-$day-$year’;

$input = trim($input);
$time = strtotime($input);
$is_valid = checkdate($month,$day,$year) == $input;

$birthday = $year . “-” . $month . “-” . $day;
$plusSeven = strtotime($birthday . “+7 days”);
$plusSeven = date( ‘Y-m-d’, $plusSeven);

print "Your birthdate is " . $birthday;
print “
”;
print “
”;
print "7 days later than your birthdate is " . $plusSeven;
print “
”;
print “
”;
print "Your birthdate is ".($is_valid ? ‘valid’ : ‘invalid’);
print “
”;
print “
”;

?>
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service