sorting date and time using php

by Jayanthi 2012-06-27 12:20:29

sorting date and time using php

<?php

$timearr = array(
"2012-06-11 08:30:49","2012-06-07 08:03:54","2012-05-26 23:04:04",
"2012-05-27 08:30:00","2012-06-08 08:30:55","2012-06-27 08:40:00","2012-06-27 08:35:00"
);

$max = max(array_map('strtotime', $timearr));
echo "Maximum : ".date('Y-m-j H:i:s', $max)."<br><br>Sorting DateTime <br><br>";

$newarray=array_map('strtotime', $timearr);
arsort($newarray);
foreach($newarray as $key => $value)
echo date('Y-m-j H:i:s', $value)."<br>";
?>



output

Maximum : 2012-06-27 08:40:00

Sorting DateTime

2012-06-27 08:40:00
2012-06-27 08:35:00
2012-06-11 08:30:49
2012-06-8 08:30:55
2012-06-7 08:03:54
2012-05-27 08:30:00
2012-05-26 23:04:04

Tagged in:

849
like
0
dislike
0
mail
flag

You must LOGIN to add comments