Results 1 to 5 of 5

Thread: How would I...

  1. #1
    Join Date
    Feb 2007
    Location
    Essex, England
    Posts
    1,392
    Tokens
    0

    Latest Awards:

    Default How would I...

    display items from a SQL database in order of date and time from those closest to the current date to those furthest away?

    For example:

    29-10-2008 18.00
    28-10-2008 18.00
    29-10-2008 17.00

    Would come out as:

    28-10-2008 18.00
    29-10-2008 17.00
    29-10-2008 18.00

    Thnks, +rep xx


  2. #2
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    set the field type to date + time in PhpMyAdmin, then do

    SELECT * FROM `tablename` ORDER BY `tablename`.`colname`
    Lets set the stage on fire, and hollywood will be jealous.

  3. #3
    Join Date
    Feb 2007
    Location
    Essex, England
    Posts
    1,392
    Tokens
    0

    Latest Awards:

    Default

    I did wonder if that was possible, cheers. Does that work with self-inserted dates?
    Last edited by L?KE; 26-10-2008 at 07:09 PM.


  4. #4
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Why not just insert a unix timestamp and then convert it into your custom date format later.

  5. #5

    Default

    Simon is right, the unix timestamp will ensure precision (to the second) and will not require you to convert via a series of regex or explodes etc. All you'll have to use the date function for displaying it date("d/m/Y", $timestamp);

Posting Permissions

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