Page 2 of 2
Re: Order text of database result
Posted: Thu Oct 06, 2011 2:03 am
by stijn22
From my free test webhost: PHP version 5.2.*

So, is there an other solution?
Re: Order text of database result
Posted: Sat Oct 08, 2011 6:04 am
by stijn22
Nobody knows? I need it as fast as possible.
Re: Order text of database result
Posted: Tue Oct 11, 2011 9:02 am
by stijn22
Can't it be done with substrings?
Re: Order text of database result
Posted: Tue Oct 11, 2011 9:32 am
by VladSun
Re: Order text of database result
Posted: Thu Oct 13, 2011 3:02 am
by stijn22
I can see that it outputs this:
[year] => 2006
[month] => 12
[day] => 12
But that is not exactly what I want, can I modify that?
Re: Order text of database result
Posted: Thu Oct 13, 2011 3:11 am
by VladSun
stijn22 wrote:I can see that it outputs this:
[year] => 2006
[month] => 12
[day] => 12
But that is not exactly what I want, can I modify that?
Yes, you can.
Re: Order text of database result
Posted: Thu Oct 13, 2011 4:47 pm
by pickle
strtotime() understands MySQL's date format, so this will work:
Code: Select all
$date = date('d-m-Y',strtotime($list->datum));
I also support the opinion of leaving the field as the DATE type. You can convert to a UNIX timestamp either with PHP's strtotime(), or MySQL's UNIX_TIMESTAMP() function, if you need a timestamp. The DATE type is much more readable if you're ever in the database manually.
Re: Order text of database result
Posted: Sat Oct 15, 2011 4:56 pm
by stijn22
Thanks! It's is now working
I also want to leave the field DATE type, since I can easely sort them by ASC when the field is DATE.
Thanks again all of you, I've learned some great new php stuff
