How to sort an array by date having datetime as stamp mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lovelf
Forum Contributor
Posts: 153
Joined: Wed Nov 05, 2008 12:06 am

How to sort an array by date having datetime as stamp mysql

Post by lovelf »

Code: Select all

 array('primary2'=>'1','friends'=>'5KZM3ZWBXO3KR7FYR74GTO096HD3V14GUTRISP4QLE78QPRGK6I3W7F','datetimep'=>'2012-02-17 19:08:42'),
  array('primary2'=>'2','friends'=>'5FTHIR9V0MK2IK1XP7ZUQ09XXPECDUVZI0OPIUURQMF1S0IAKL0390Z','datetimep'=>'2012-02-17 19:08:48')
How to sort an array by date? I have 'datetimep' which holds a datetime stamp in the mysql table, I wonder how to after selecting all from the table sort by date the values on a separate array.
Last edited by lovelf on Sat Feb 18, 2012 6:41 am, edited 1 time in total.
User avatar
StathisG
Forum Newbie
Posts: 14
Joined: Sat Mar 13, 2010 7:15 pm
Location: UK

Re: How to sort by date

Post by StathisG »

You might find useful one of these answers. Another way is to convert them to timestamps and sort them this way, but why don't you just sort them in your MySQL query?
Post Reply