我有下面的数组
@H_404_1@array(5) {
[0]=> string(19) "2012-06-11 08:30:49"
[1]=> string(19) "2012-06-07 08:03:54"
[2]=> string(19) "2012-05-26 23:04:04"
[3]=> string(19) "2012-05-27 08:30:00"
[4]=> string(19) "2012-06-08 08:30:55"
}
并且想知道最近的日期如:最接近今天的日期.
我怎样才能做到这一点?
执行循环,将值转换为日期,并将最近的值存储在var中.
@H_404_1@$mostRecent= 0;
foreach($dates as $date){
$curDate = strtotime($date);
if ($curDate > $mostRecent) {
$mostRecent = $curDate;
}
}
这样的事情…你会得到这个想法
如果您希望今天以前最近: