I want to always echo out the date 3 days from now. So right now I have:
$date = date("l F jS");
echo $date;
Which echos "Friday June 5th"
What exactly do I do so that it echos out "Monday June 8th" and tomorrow it echos out "Tuesday June 9th" (always 3 days ahead).
You can use strtotime()
with a relative date format. When you pass a Unix timestamp as the second parameter to date()
it will format that date.
$date = date("l F jS", strtotime('+3 days'));
echo $date;
Or if you prefer OOP use DateTime()
. With DateTime()
you can put the relative date format right into its constructor. It also handles things like daylight savings time which may come into play depending on what you're doing.
$date = new DateTime('+3 days');
echo $date->format("l F jS");