?$hours,?"min"?=>?$mins,?"sec"?=>?$secs?);?????return?$res;?}?//========">
时间:2021-07-01 10:21:17 帮助过:14人阅读
function?timediff(?$begin_time,?$end_time?)? {? ????if?(?$begin_time?$end_time?)?{? ????????$starttime?=?$begin_time;? ????????$endtime?=?$end_time;? ????}?else?{? ????????$starttime?=?$end_time;? ????????$endtime?=?$begin_time;? ????}? ????$timediff?=?$endtime?-?$starttime;? ????$days?=?intval(?$timediff?/?86400?);? ????$remain?=?$timediff?%?86400;? ????$hours?=?intval(?$remain?/?3600?);? ????$remain?=?$remain?%?3600;? ????$mins?=?intval(?$remain?/?60?);? ????$secs?=?$remain?%?60;? ????$res?=?array(?"day"?=>?$days,?"hour"?=>?$hours,?"min"?=>?$mins,?"sec"?=>?$secs?);? ????return?$res;? }? //========?实例使用 ========? $timediff?=?timediff(?strtotime(?"2011-10-28"?),?strtotime(?"2011-10-29"?)?);? print_r(?$timediff?);? ?> |