織夢CMS時間格式實現XX秒前、XX分鐘前、XX天前織
導讀:織夢技巧織夢技巧打開 /include/extend.func.php 在最下面加入個方法 /** * 時間美化 * * @access public * @param str百度seo網站優化seo網站關鍵詞優化。
打開 /include/extend.func.php 在最下面加入個方法 /** * 時間美化 * * @access public * @param string $time 時間戳 * @return string */ if (!function_exists( tranTime )){ function tranTime ($time) {$rtime = date( m-d H:i ,$time);$htime = date( H:i ,$time);$etime = time() - $ti […]
打開 /include/extend.func.php 在最下面加入個方法
/** * 時間美化 * * @access public * @param string $time 時間戳 * @return string */ if(!function_exists('tranTime')) { function tranTime($time) { $rtime = date("m-d H:i",$time); $htime 公司網站建設= date("H:i",$time); $etime = time() - $time; if ($etime < 1) return '剛剛'; $interval = array ( 12 * 30 * 24 * 60 * 60 => ' 年 前', 30 * 24 * 60 * 60 => ' 個 月 前', 7 * 24 * 60 * 60 => ' 周 前', 24 * 60 * 60 => ' 天 前', 60 * 60 => ' 小 時 前', 60 => ' 分 鐘 前', 1 => ' 秒 前' ); foreach($interval as $secs => $s網站建設教程tr) { $d = $etime / $secs; if($d >= 1) { $r = round($d); return $r . $str; } }; } }調用標簽寫法
首頁/列表頁
[field:pubdate function="tranTime(@me)"/]內容頁
{dede:field.pubdate function="tranTime(@me)"/}如果你的時間格式是 2018-10-10 這種正常時間,那要這樣寫調用標簽
[field:pubdate function="tranTime(GetMkT網站建設制作ime(@me))"/] {dede:field.pubdate function="tranTime(GetMkTime(@me))"/}相關百度seo網站優化seo網站關鍵詞優化。聲明: 本文由我的SEOUC技術文章主頁發布于:2023-05-25 ,文章織夢CMS時間格式實現XX秒前、XX分鐘前、XX天前織主要講述標簽,格式,CMS網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_8185.html