3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dateWord($from, $now) { $timezone = new DateTimeZone('Asia/Shanghai'); $now = new DateTime($now, $timezone); $from = new DateTime($from, $timezone); $between = $now->diff($from); if(!$between->invert) return false; /** 如果超过了一年 **/ if($between->y) return $from->format('Y年m月d日'); /** 一年内大于七天 **/ if($between->days > 6) return $from->format('n月j日'); /** 一个礼拜内但是大于两天**/ if($between->days > 1) return $between->format('%d天前'); /** 如果是昨天 **/ if($between->days) return $from->format('昨天 H:i'); /** 如果一天之内超过一个小时 **/ if($between->h > 1) return $between->format('%h小时前'); if($between->i > 1) return $between->format('%i分钟前'); return $between->s ? $between->format('%s秒前') : '刚刚'; } function dateWordToHtml($from, $now = 'now') { echo $dateWord = dateWord($from, $now); $from = new DateTime($from, new DateTimeZone('Asia/Shanghai')); $fromWord = $from->format('Y年m月d日 H:i'); return "<span title=\"$fromWord\">$dateWord</span>"; } //dateWord()函数对应的是Typecho原版的返回,dateWordToHtml()函数则是对应你修改的那个函数 echo dateWordToHtml("2014/4/14 9:32");
Output for git.master, git.master_jit, rfc.property-hooks
6天前<span title="2014年04月14日 09:32">6天前</span>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.07 ms | 401 KiB | 8 Q