Get most recent date from an array of dates

后端 未结 11 682
小鲜肉
小鲜肉 2020-11-28 11:32

I have the array of dates below

array(5) { 
    [0]=> string(19) \"2012-06-11 08:30:49\" 
    [1]=> string(19) \"2012-06-07 08:03:54\" 
    [2]=> st         


        
11条回答
  •  清酒与你
    2020-11-28 11:51

    Sort the array by date, and then get the front value of the array.

    $dates = array(5) { /** omitted to keep code compact */ }
    $dates = array_combine($dates, array_map('strtotime', $dates));
    arsort($dates);
    echo $dates[0];
    

提交回复
热议问题