有没有一种函数或方法可以按顺序对 strtotime 日期进行排序并将其转换回可读日期?

Is there a function or a way to sort strtotime dates by order and convert it back to readable date?

我已经将这个日期数组转换为 strtotime:

Array ( [0] => 1481760000 [1] => 1482192000 [2] => 1478476800 [3] => 1482019200 ) 

有没有函数可以sort/order这个数组降序排列,然后再转换回可读的日期格式?

demo here.

<?php
$array =array ( 1481760000, 1482192000, 1478476800, 1482019200 ) ;
usort($array, function($a, $b){return $b - $a;});
$array = array_map( function($item){return date("Y-m-d H:i:s", $item);}, $array);
echo json_encode($array);

使用PHP的sort with array_reverse

sort($arrayOfTimestamps);
$arrayOfTimestamps = array_reverse($arrayOfTimestamps);

$arrayOfReadableDates = array();

foreach($arrayOfTimestamps as $timestamp) {
    $arrayOfReadableDates[] = date('l jS \of F Y h:i:s A', $timestamp);
}

试试下面的。

$arr = Array ( [0] => 1481760000, [1] => 1482192000, [2] => 1478476800, [3] => 1482019200 );

asort($arr); //     low to high
or 
arsort($arr); //    high to low

foreach ($arr as $key =>$val) { 
     $arr[$key] = date('Y-m-d H:i:s', $val); // 'Y-m-d H:i:s' - update what date format you want

}