How do I add 1 week to a date function with separate date variables. The date needs to be separate so I can insert it into another form. If I cant do it as separate variables can i separate them afterwards?
So:
$year = date("Y");
$month = date("m");
$day = date("d");
echo 'Current Date' . $year . '.' . $month . '.' . $day;
echo 'Date 1 Week in the Future';
Use strtotime
:
echo "Date 1 Week in the Future " . date('Y.m.d', strtotime('+1 Week'));
// Outputs: Date 1 Week in the Future 2012.03.10
To break up into separate variables (as per your comment):
$oneWeekLater = strtotime('+1 Week');
$year = date('Y', $oneWeekLater);
$month = date('m', $oneWeekLater);
$day = date('d', $oneWeekLater);
echo 'Date 1 Week in the Future' . $year . '.' . $month . '.' . $day;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With