Im trying to set a form in which people can insert dates. For example they can insert their birthday. However Im not sure in which format they should be entered in.
Is there a standard method of dealing wth dates. Should I have one column for day, one for the month and one for the year. Or should they all be entered into one column.
Is there standard way of using dates?
The date input on the form should ideally be split into three dropdown boxes (Year, Month, Day) then you stick them all together as a single string with a delimiter character when it gets to the webserver eg: 1968-12-23 This way there is no chance of people stuffing up the format or putting in stupid dates, now the string can then be inserted into a single column of a typical SQL database. If the column format/attribute is set to ‘Datetime’ you can then use SQL commands to easily sort the rows of data by the users birthdays.
or else feed it through strtotime, and reject the form submission if you get false back; that way you can accept the standard formats. The dropdowns are the better solution.
Here are some old discussions on dealing with dropdown date pickers and handling the input.
There are many more if you want to use Advanced Search