网站首页要调用最新发布的数篇文章,为了实现一个日期效果,修改了 typecho 程序文件的 Date.php 文件,位于:
/var/Typecho/Date.php
第 104-105 行,原来代码是:
...
case 'month':
return date('m', $this->timeStamp);
...
更改后的代码是:
...
case 'month':
return date('M', $this->timeStamp);
...
只是把 m 改为 M。
小写的 m 呈现的效果是以两位数字组合的月份,即:01,02,...,12 ;
大写的 M 呈现的效果则是英文月份的简称:Jan, Feb,...,Dec 。
因为我习惯记录日期的格式如:02MAY2017,所以在网站上的日期设计也倾向如此,英文月份的简称统一大写,则用 CSS 强制执行:
text-transform: uppercase;
此问题没有解决,如果更改这个文件,发现会影响由月份构成的伪静态链接。
解决方法在:$this->xxx->to 和 $this->xxx->parse
相关代码:
<h2>recent</h2>
<?php $this->widget('Widget_Contents_Post_Recent', 'pageSize=5')->to($recentPosts); ?>
<ol>
<?php while ($recentPosts->next()): ?>
<li><time><?php $recentPosts->date('dM'); ?></time><a href="<?php $recentPosts->permalink(); ?>" title="<?php $recentPosts->title(); ?>"><?php $recentPosts->title(); ?></a></li>
<?php endwhile; ?>
</ol>