Closed Thread
Results 1 to 3 of 3

Thread: PHP and MySQL - Dates?

  1. #1
    VIP conkermaniac is on a distinguished road conkermaniac's Avatar
    Join Date
    Dec 2001
    Location
    China--soon to be Cambridge MA
    Posts
    5,794

    PHP and MySQL - Dates?

    Hi,

    I'm a bit of a newbie to PHP and MySQL, and I have trouble working with dates (in any programming language). Could someone please advise me as to how I can sort dates, if they are stored as a character string? If that's not possible, is it possible to store dates as DATETIME, and then change the format after the values are brought out of the database? Thanks for your help.
    a.aimoo.com - Get your forum reviewed here!
    desilva.biz - Great webmaster tips and tricks!
    webmaster-talk.com - Discussion forum for all webmasters

  2. #2
    Pro Member hohoho is an unknown quantity at this point hohoho's Avatar
    Join Date
    Apr 2002
    Location
    localhost
    Posts
    456
    you can store them in DATETIME and change their format in the select...

    SELECT DATE_FORMAT(datetime_col, '%d.%m.%Y') AS new_datetime_col FROM table ORDER BY datetime_col DESC

    just replace %d.%m.%Y with your format
    Last edited by hohoho; March 1st, 2003 at 07:39.
    There are 3 kinds of people: the ones who can count and the others who cannot

  3. #3
    VIP conkermaniac is on a distinguished road conkermaniac's Avatar
    Join Date
    Dec 2001
    Location
    China--soon to be Cambridge MA
    Posts
    5,794
    Thanks! I will try that out now.
    a.aimoo.com - Get your forum reviewed here!
    desilva.biz - Great webmaster tips and tricks!
    webmaster-talk.com - Discussion forum for all webmasters

Closed Thread

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