Setting up an online appointment script where I'm looking to always have 14 days in advance shown. When the page is shown it gets the current date and deletes all previous dates. Then I need to get the last Date in the database and add the appropriate amount of days to the end. Problem is the Dates in the database are month and day ex. March 31. No matter what I try it doesn't pull the last date, which is April 8 but shows April 4. Using order by then limit 1.
Do I need to store the Dates in a different format, or is there a way to get them to sort correctly.
Any help would be appreciated
Thanks
order by Date (online appointment)
Moderator: General Moderators
Re: order by Date (online appointment)
if they have a unique id that has been save too such as 1,2,3,4,5,6 in order say for auto increment then you could if the dates are in the right order for each id just sort by id instead. Just an idea otherwise you are best saving the dates as a different format really, or converting to different format to work out what you require.
Best wishes
Best wishes
Re: order by Date (online appointment)
That actually might do the trick, but would it be a better practice to save the dates as a different format to avoid future problems? If so which format is best supported for ordering by date.
Thanks
Thanks
Re: order by Date (online appointment)
You can use microtime or time which will give you the exact seconds that have passed since 1st January 1970. Its precise and can be used in many conversions. I always use it and then you can convert it back to a readable format for displaying it.
Best wishes
Best wishes
Last edited by phphelpme on Wed Mar 28, 2012 4:46 pm, edited 1 time in total.
Re: order by Date (online appointment)
All you would do then is add the value for 14 days in microtime or time to the last database entry and thats it. Then display as different format for visual reading.
Best wishes
Best wishes