您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
三六零分类信息网 > 克拉玛依分类信息网,免费分类信息发布

PHP版实现友好的时间显示方式(例如:2小时前)

2025/11/29 4:29:39发布10次查看
完整php类,通常我会配合smary使用,快捷使用 (plugins/function.rdate.php)
200601*/){ return date('ym',strtotime('+1 month',strtotime($month.'01')));}function prevmonth($month/*200512->200511*/){ return date('ym',strtotime('-1 month',strtotime($month.'01')));}function prevday($day/*20050826*/){ $day = substr($day,0,8); return date('ymd',strtotime('-1 day',strtotime($day)));}function nextday($day/*20050826*/){ $day = substr($day,0,8); return date('ymd',strtotime('+1 day',strtotime($day)));}function nextexistsday($day/*20050109*/){ $day = nextday($day); while(!hastopic($day) && $day $day = nextday($day); } return hastopic($day) ? $day : false;}function prevexistsday($day/*20050109*/){ global $cfg; $day = prevday($day); while(!hastopic($day) && (int)$day > $cfg->origdate){ $day = prevday($day); } return hastopic($day) ? $day : false;}function prev_day($day){$day = substr($day,0,8);return date('ymd',strtotime('-1 day',strtotime($day)));}function long_date($ts){return date(y年n月d日,$ts);}function day2time($day){return @strtotime($day);}/*echo ;
echo strftime(a%a\n); // a 星期二 echo strftime(a%a\n); // a 星期二 echo strftime(b%b\n); // b 四月 echo strftime(b%b\n); // b 四月 echo strftime(c%c\n); // c 2006-4-18 3:48:11 echo strftime(c%c\n); // c echo strftime(d%d\n); // d 18 echo strftime(d%d\n); // d echo strftime(e%e\n); // e echo strftime(g%g\n); // g echo strftime(g%g\n); // g echo strftime(h%h\n); // h echo strftime(h%h\n); // h 03 echo strftime(i%i\n); // i 03 echo strftime(j%j\n); // j 108 echo strftime(m%m\n); // m 04 echo strftime(m%m\n); // m 48 echo strftime(n%n\n); // n echo strftime(p%p\n); // p 上午 echo strftime(r%r\n); // r echo strftime(r%r\n); // r echo strftime(s%s\n); // s 11 echo strftime(t%t\n); // t echo strftime(t%t\n); // t echo strftime(u%u\n); // u echo strftime(u%u\n); // u 16 echo strftime(v%v\n); // v echo strftime(w%w\n); // w 16 echo strftime(w%w\n); // w 2 echo strftime(x%x\n); // x 2006-4-18 echo strftime(x%x\n); // x 3:48:11 echo strftime(y%y\n); // y 06 echo strftime(y%y\n); // y 2006 echo strftime(z%z\n); // z 中国标准时间 echo strftime(%%%\n); // % */
复制代码
trigger_error(rdate: missing 't' parameter); return; } $date = $params['t']; if (!preg_match('/^\d+$/', $date)) $date = strtotime(trim($date)); $sec = time() - $date; switch(true){ case $sec return round($sec/60). ' 分钟前'; case $sec return round($sec/3600). ' 小时前'; case $sec return round($sec/86400). ' 天前';//days ago case $sec return round($sec/(86400*7)). ' 周前'; //weeks ago default: return date(y年n月d日,$date); }}?>
复制代码
克拉玛依分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product