Vulture276
Vulture276

Reputation: 11

Date Changing Interval

Not much coding experience, but hoping the community can help. I'd like to have a simple HTML headline read the following:

"Meals are available for pickup on Sunday,February 23 and Monday, February 24."

The crux is I need this to change every Thursday at 1 p.m. so that the dates change to the dates of the FOLLOWING Sunday & Monday.

--

We are a meal prep service with new menus every week. Order cut off is every Thursday @ 1 p.m. I've automated the site's meal menu to rotate at this time. With this dynamic headline, I hope to avoid customer confusion so that if someone orders on Thursday @ 2 p.m., they know their meals aren't going to be available until the following weekend.

Hope that makes sense. Thanks in advance for the help!

Upvotes: 1

Views: 45

Answers (1)

Object object
Object object

Reputation: 2054

You can do this quite easily using the php time functions

Example:

<?php
$monday_date = strtotime('next monday');
$sunday_date = strtotime('next sunday');
?>
<!-- Some content -->
<div class="header">Meals are available for pickup on Sunday,February $sunday_date and Monday, February $monday_date</div>
<!-- Some more content -->

The above example wont rotate at 1pm but will show the date of the closest sunday/monday. I leave it as an exercise to the reader to work out how to adapt it for timings (hint: the time library can detect the current time)

Upvotes: 1

Related Questions