Ok, so i've done loads of searching and tried various ways to add a week to a date, this is what i have got.
I'm trying to obtain next weeks dates. I have got it down to this bit of code not functioning right, even though it is published this exact way in multiple tutorials.
<?php
$now = date('d/m/Y');
$nextWeek = date('d/m/Y', strtotime('+1 week'));
$monday = date('d/m/Y', strtotime("next monday"));
$tuesday = date('d/m/Y', strtotime("next tuesday"));
$wednesday = date('d/m/Y', strtotime("next wednesday"));
$thursday = date('d/m/Y', strtotime("next thursday"));
$friday = date('d/m/Y', strtotime("next friday"));
$saturday = date('d/m/Y', strtotime("next saturday"));
$sunday = date('d/m/Y', strtotime("next sunday"));
if ($nextWeek > $monday) {
$monday = date('d/m/Y', strtotime("next monday", '+1 week'));
}
if ($nextWeek > $tuesday) {
$tuesday = date('d/m/Y', strtotime("next tuesday", '+1 week'));
}
if ($nextWeek > $wednesday) {
$wednesday = date('d/m/Y', strtotime("next wednesday", '+1 week'));
}
if ($nextWeek > $thursday) {
$thursday = date('d/m/Y', strtotime("next thursday", '+1 week'));
}
if ($nextWeek > $friday) {
$friday = date('d/m/Y', strtotime("next friday", '+1 week'));
}
if ($nextWeek > $saturday) {
$saturday = date('d/m/Y', strtotime("next saturday", '+1 week'));
}
if ($nextWeek > $sunday) {
$sunday = date('d/m/Y', strtotime("next sunday", '+1 week'));
}
echo "<br />";
echo "Today: " . $now;
echo "<br />";
echo "Next Week: " . $nextWeek;
echo "<br />";
echo "Monday: " . $monday;
echo "<br />";
echo "Tuesday: " . $tuesday;
echo "<br />";
echo "Wednesday: " . $wednesday;
echo "<br />";
echo "Thursday: " . $thursday;
echo "<br />";
echo "Friday: " . $friday;
echo "<br />";
echo "Saturday: " . $saturday;
echo "<br />";
echo "Sunday: " . $sunday;
echo "<br />";
?>I'm trying to obtain next weeks dates. I have got it down to this bit of code not functioning right, even though it is published this exact way in multiple tutorials.
$sunday = date('d/m/Y', strtotime("next sunday", '+1 week'));

Help
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Back to top









