In article <fPadnQQ0M5JfNkWiU-KYjA@giganews.com>,
"Yulia Yegenov" <yuliay@nospam.noadd.ru> wrote:
[color=blue]
> I have a query that looks like this: (I insert the date created with the php
> date function)
>
> //(I cannot use the mysql timestamp function for other reason).
> $curdate = date("m/j/Y H:i");
>
> [major snip]
>
> if I order the tickets by submission time, it orders the items, but not
> correctly. It looks like php treating the submissiontime like integer:[/color]
Actually it's MySQL doing that, but you're right about the order.
[color=blue]
> 12/1/2003 16:51
>
> 12/1/2003 16:58
>
> 12/10/2003 12:29
>
> How can I tell php treat the submissiontime field in mysql as a date so it
> can be ordered correctly? I need to do this so I can do some maths and some
> sorting on the the date.[/color]
Use date('m/d/Y H:i') instead, so that the day gets zero-padded. This
should get MySQL to sort them the way you need, e.g. 12/01 will come
before 12/10.
Or, you could use a datetime column in the MySQL table (assuming you
aren't already).
hth
--
Bulworth :
funha@fung.arg | My email address is ROT13 encoded, decode to mail
--------------------------|--------------------------------------------------
<http://www.phplabs.com/> | PHP scripts and thousands of webmaster resources!