September 30th, 2013, 08:12 AM
-
PHP Stops Producing Dates After December 31st
Hi guys,
I've created a booking form on my website for people to book appointments from a list of dates. I have it set to produce 120 days from the current day. It's been working fine all year but since the 120th day has hit December 31st/Jan 1st it's no longer producing the list. I can only assume this is due to it trying to look further than December in the same year - which there obviously isn't any more days in this year... So, how do I get it to start a new year, from Jan 1st..?
Any help would be great.
PHP Code:
<option selected disabled value="select-date">Select a date</option> <?php date_default_timezone_set('Europe/London'); // Start date $date = date('l jS F'); // End date $end_date = date('l jS F', strtotime("+120 days")); while (strtotime($date) <= strtotime($end_date)) { echo "<option value=\"$date\n\">$date\n</option>"; $date = date ('l jS F', strtotime("+1 days", strtotime($date))); } ?> </select>
September 30th, 2013, 08:36 AM
-
Ummm... This list they get to choose from, is it a drop-down selection? If so, I would recommend changing to a text input. If you are worried about them entering a date outside your 120 day range, there are ways to make sure this doesn't happen. Personally, I use the Datepicker offered within jQuery. This will offer a visual calendar for the individual to select a date from, as well as offer you the ability to add restrictions of the date range.
EDIT: The calendar DOES offer better views/themes, so the others actually look alot better than the one in the example.
Last edited by Triple_Nothing; September 30th, 2013 at 10:47 AM.
He who knows not that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.
September 30th, 2013, 08:44 AM
-
Hi thanks for you comments.
Yes it's a dropdown list. The calendar picker is interesting. Is it possible for me to style it myself?
September 30th, 2013, 08:52 AM
-
As long as one knows his coding, he can do anything...
He who knows not that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.
September 30th, 2013, 08:56 AM
-