Jump to content

Recommended Posts

i have a little problem, i need to order a query by date.

but in the db, the date field is formulated "14.01.2008" instead of "2008.01.14"

 

so the result is my output is all scrambled.

 

i have alot of other scripts reading from this db so changing the field is not an option as it will mess up the other scripts.

 

is there somrthing in the php query that i can add to output that data corectly?

 

thanks

 

Piet

Link to comment
https://forums.phpfreaks.com/topic/85919-order-by-date-desc/
Share on other sites

Something like the code shown below would rearrange the date AFTER you have extracted all the rows from the db.

 

function rearrange($date) {
$parts=explode(".", $date);
$newdate=$date[3].".".$date[2].".".$date[1];
}

 

As for changing the way you query the db, I really think to make it simpler in the long run it's easier to change the column in the database, after all you can always call a common function from every other php file that needs the date to arrange the date in the way you normally use it.

Link to comment
https://forums.phpfreaks.com/topic/85919-order-by-date-desc/#findComment-438663
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.