<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_61052"> 時間は、「1天前」、「2月前」などのような形式に変換されます。 <div class="blockcode"> <div id="code_J89"><ol> <li> <?php<li>function prettyDate($date){<li> $time = strtotime($date);<li> $now = time();<li> $ago = $now - $time;<li> if($ago < 60){<li> $when =round($ago);<li> $s = ($ when == 1)?"second":"秒";<li> return "$when $s ago";<li> }elseif($ago < 3600){<li> $when =round($ago / 60);<li> $m = ($when == 1)?"分":"分";<li> return "$when $m ago";<li> }elseif($ago >= 3600 && $ago $when =round ($ago / 60 / 60);</li> <li> $h = ($when == 1)?"hour":"hours";</li> <li> return "$when $h ago";</li> <li> }elseif($ago >= 86400 && $ago $when =round($ago / 60 / 60 / 24);</li> <li> $d = ($when == 1)?"day":"days";</li> <li> return "$when $d ago";</li> <li> }elseif($ago >= 2629743.83 && $ago $when =round($ago / 60 / 60 / 24 / 30.4375);</li> <li> $m = ($when == 1) ?"month":"months";</li> <li> return "$m 前 $when";</li> <li> }else{</li> <li> $when =round($ago / 60 / 60 / 24 / 365);</li> <li> $y = ($when == 1)?"year":"year";</li> <li> return "$when $y ago";</li> <li> }</li> <li>}</li> <li> <li>echo prettyDate("2012-07-22 12:23:45")."<br /> ;";</li> <li>echo prettyDate("2010-11-12 22:25:45")."<br />";</li> <li>echo prettyDate("2012-01-01 01:00:00")."< ;br />";</li> <li>echo prettyDate("2001-05-30 00:00:00")."<br>"; </li> </ol></div> <em onclick="copycode($('code_J89'));">复制代</em> </div> <br> </td></tr></table> <div class="ptg mbm mtn"> 几天、转成</div> <div id="comment_61052" class="cm"> </div> <div id="post_rate_div_61052"></div> <br><br>