Results 1 to 4 of 4

Thread: php5, MySQL date problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Godzone, oops Oz
    Posts
    355

    Red face php5, MySQL date problem

    Has anyone found anything like a tutorial anywhere on the net dealing with selection of MySQL via date.

    I want to write a date to a record? (What format what field type)

    I want to then be able to select records ordering by the date field.

    Strangely I can't find anything on the net.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Godzone, oops Oz
    Posts
    355

    Re: php5, MySQL date problem

    Ok have got this far

    SELECT * FROM table_name ORDER BY date_ent DESC LIMIT 10

    NOW() seems the best bet for getting the current date time into the record

  3. #3
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: php5, MySQL date problem

    you can use the DATETIME data type. the format is YYYY-MM-DD HH:MM:SS, where HH is 0-23. I don't know what else you're asking for, since you've already used ORDER BY.

    NOW() is the function to use if you want a DATETIME, whereas CURDATE() would be used for just a DATE, and CURTIME() would be used for just a TIME.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Godzone, oops Oz
    Posts
    355

    Re: php5, MySQL date problem

    Should have an actual question by tomorrow when I try all this new found goodness out

Posting Permissions

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



Click Here to Expand Forum to Full Width