<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_65585"> <div class="blockcode"> <div id="code_QWW"><ol> <li>function DateDiff($date1, $date2, $unit = "") { //时间比较函数,返回两个日期相差几秒、几分钟、几小时或几天</li> <li> switch ($unit) {</li> <li> case 's':</li> <li> $dividend = 1;</li> <li> break;</li> <li> case 'i':</li> <li> $dividend = 60; //oSPHP.COM.CN</li> <li> break;</li> <li> case 'h':</li> <li> $dividend = 3600;</li> <li> break;</li> <li> case 'd':</li> <li> $dividend = 86400;</li> <li> break; //开源OSPhP.COM.CN</li> <li> default:</li> <li> $dividend = 86400;</li> <li> }</li> <li> $time1 = strtotime($date1);</li> <li> $time2 = strtotime($date2);</li> <li> if ($time1 && $time2)</li> <li> return (float)($time1 - $time2) / $dividend;</li> <li> return false;</li> <li>} </li> </ol></div> <em onclick="copycode($('code_QWW'));">复制代码</em> </div> <br> </td></tr></table> <div class="ptg mbm mtn"> 几天, 几分钟, 几秒</div> <div id="comment_65585" class="cm"> </div> <div id="post_rate_div_65585"></div> <br><br>