SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    731
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Dealing With Dates?

    Hi,

    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?

  2. #2
    SitePoint Zealot Sogo7's Avatar
    Join Date
    May 2011
    Posts
    129
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    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.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Here are some old discussions on dealing with dropdown date pickers and handling the input.

    http://www.sitepoint.com/forums/show...elector-Script

    http://www.sitepoint.com/forums/show...ate-validation

    There are many more if you want to use Advanced Search


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •