SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Date formatting question

    Hopefully a quick question on date formatting...

    Basically I have a few date fields in a table - last updated, next check due etc.

    There's also a DateAdded field which defaults to the date the record was created. The default format was 2008-01-01, but I've got that displaying using a recordset in Dreamweaver :

    SELECT date_format(DateAdded, '%%D %%b %%Y') as formatted_date FROM developments WHERE DevelopmentID = %s", $colname_dateformat1);

    This is fine.

    Following this principle I've done another couple for other dates and dropped them in. For dated I'd already added in the 2008-01-01 format, they display correctly.

    But my problem now is with entering them - as far as I can tell I'm drawing a blank with either

    2008-01-01 or '%%D %%b %%Y'

    What's the best practice for entering them in the first place?

    Cheers,

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    The best practice is to enter them using MySQL's date datatype.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK - sorted the first bit - so I guess my question is really how to deal with users coming along and entering a date as :

    01 01 07, or 01-01-2007

    instead of 2007-01-01

  4. #4
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    The best practice is to enter them using MySQL's date datatype.
    ie YYYY-MM-DD?

    I've just put that in brackets by the date fields, so I guess that'll do.

    I guess as a non techie coming from an Access background, I'm used to it automagically changing pretty much anything entered into the format for the field.


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
  •