0

i have array like this:

Array
(
    [4] => Array
        (
            [dep] => 23:24
            [seconds] => 84240
            [date] => 2014-05-15 23:24:00
        )

    [3] => Array
        (
            [dep] => 04:49
            [seconds] => 17340
            [date] => 2014-05-16 04:49:00
        )

    [2] => Array
        (
            [dep] => 04:22
            [seconds] => 15720
            [date] => 2014-05-16 04:22:00
        )

    [1] => Array
        (
            [dep] => 04:07
            [seconds] => 14820
            [date] => 2014-05-16 04:07:00
        )

    [0] => Array
        (
            [dep] => 00:04
            [seconds] => 240
            [date] => 2014-05-16 00:04:00
        )

)

I would like sort and get something like: 1. 2014-05-15 23:24:00

  1. 2014-05-16 00:04:00

  2. 2014-05-16 04:07:00

  3. 2014-05-16 04:22:00

  4. 2014-05-16 04:49:00

Thanks for replay ;)

demo.b
  • 3,299
  • 2
  • 29
  • 29
Kamilos
  • 39
  • 1
  • 7

3 Answers3

0

How about translating the values into unix time and sorting by that?

Tom Teman
  • 1,975
  • 3
  • 28
  • 43
  • //your array with details $datatimearray; $tmparray = array() foreach($datatimearray as $key => $val) { $settime = strtotime($val); } ksort($tmparray); $datatimearray = $tmparray; print_r($datatimearray); – Harsh Chunara Mar 31 '14 at 12:49
0

Thats probably the easiest solution:

sort(strtotime($array['date']));
Realitätsverlust
  • 3,941
  • 2
  • 22
  • 46
0

Use strtotime on each of those fields and then sort them with asort.

Uriziel
  • 177
  • 1
  • 10