Re: order by date
| From: | Kevin Stone | Date: | Fri, 11 Apr 2003 17:11:48 +0000 |
| Subject: | Re: order by date | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-143540@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "joe" <cdmvirt@cdmvirtual.com>
To: <php-general@lists.php.net>
Sent: Friday, April 11, 2003 10:49 AM
Subject: [PHP] order by date
> Ok I am trying to order my info via a non standard date
>
> being day-month-year
>
> so I use ORDER BY date ASC
>
> but it does order correctly
>
> I can change the date format because it is being sent via a program on the
> client computer...so any possibilities
I assume by "does" you mean "does not", and by "can" you mean
"can not".
Something wrong with your mail client clipping apostrophies? :)
Provided the date format remains predictable then you don't have a problem.
Parse the string into its consituate components and produce a new string
that the strtotime() function will recognize. Most commonly this would be
the "mm/dd/yyyy" or "January 01, 2003" formats. Strtotime() will output a
timestamp which you can use as the array key and sort the output with either
the ksort() or krsort() functions.
http://www.php.net/manual/en/function.explode.php
http://www.php.net/manual/en/function.strtotime.php
http://www.php.net/manual/en/function.ksort.php
HTH,
Kevin