Hello everyone,
I have a form that adds an item to a shopping cart. The user would like her items available only during certain parts of the day as she delivers the items same day, and only certain items are available on certain days.
So her shopping page looks something like this (each item is it's own form, and the buy now button submits the form):
Monday: Item 1 <buy now button>
Tuesday: Item 2 <buy now button>
Wednesday: Item 3 <buy now button>
and so on
Let's say the cutoff time is 10am
On Sunday, you will see all items with the buy now buttons. On Monday, if it's before 10am, you will see everything.
On Monday at 10:01am you will see
Monday: Item 1 "Sorry this is no longer available to order today"
Tuesday: Item 2 <buy now button>
Wednesday: Item 3 <buy now button>
So I need to either display the buy now button (which submits the form), or show a message. Which one is shown is based on the current date and time.
Any ideas??
Thanks to all and have a great day.
Rich
Display message or button dependent on datetime
Moderator: General Moderators
Re: Display message or button dependent on datetime
Compare date("Hi") with the cutoff time.
Remember:
1. Use a 24-hour clock. 5:30pm is "1730".
2. Times before 10am need a leading zero - so it's four digits. 5:30am is "0530".
You can compromise on those requirements by using more complicated code.
Code: Select all
if (date("Hi") < "1000") {
// good
} else {
// too late
}1. Use a 24-hour clock. 5:30pm is "1730".
2. Times before 10am need a leading zero - so it's four digits. 5:30am is "0530".
You can compromise on those requirements by using more complicated code.
Re: Display message or button dependent on datetime
Thanks, don't know why I didn't think of that. I guess I was over complicating things in my mind...haha
Got it, thank you very much.
Rich
Got it, thank you very much.
Rich