<?php
function getMonthNum( $date1, $date2, $tags='-' ){
$date1 = explode($tags,$date1);
$date2 = explode($tags,$date2);
return abs($date1[0] - $date2[0]) * 12 + abs($date1[1] - $date2[1]);
}
$date1 = "2005-08-11";
$date2 = "2012-11-05";
$monthNum = getMonthNum( $date1 , $date2 );
echo $monthNum;
?>
可直接运行试试,笑纳
追问漂亮!!干得好!!采纳!!但是有个BUG,你把两个时间位置换下就知道了