Dates and times are such a pain in the butt
Posted: Fri Feb 23, 2007 6:47 pm
I'm building a system that a user can add/modify/delete events in a calendar. Now there is a start date, a start time, an end date, and an end time. The trouble comes because the event doesn't necessarily have to have an "end time". It does have to have a start time, and a start date, and if they don't enter an end date it will just get set to the same as the start date.
Since there doesn't have to be an end time. I store start_date, end_date, start_time and end_time, and allow end_time to be null. So now whenever I load an event or add an event, I have to check "is this am or pm?" (0 or 12) and then set all that information and then set "checked='checked'" in my am/pm drop down as well as converting the time from hh:mm:ss to hh:mm for the user and then converting it BACK to go into the database.
I also have to convert the time from yyyy-mm-dd to mm-dd-yyyy while displaying to the user in the text input, and then convert back to yyyy-mm-dd to put it into the database.
My question is this: Is there an easier way??
Since there doesn't have to be an end time. I store start_date, end_date, start_time and end_time, and allow end_time to be null. So now whenever I load an event or add an event, I have to check "is this am or pm?" (0 or 12) and then set all that information and then set "checked='checked'" in my am/pm drop down as well as converting the time from hh:mm:ss to hh:mm for the user and then converting it BACK to go into the database.
I also have to convert the time from yyyy-mm-dd to mm-dd-yyyy while displaying to the user in the text input, and then convert back to yyyy-mm-dd to put it into the database.
My question is this: Is there an easier way??