以月曆方式顯示日期

引用:How To Make The Blogger Posts Have A Calendar For The Date In

選擇 Date Header Format

尋找以下的程式碼(有 2 段)
<h2 class='date-header'><span><data:post.dateHeader/></span></h2>

替換成以下的程式碼
<div id='Date'>
<script>changeDate(&#39;<data:post.dateHeader/>&#39;);</script>
</div>
<b:else/>
<div id='Date'>
<script>changeDate(&#39;&#39;);</script>
</div>

在</head>前面貼上以下的程式碼
<script type='text/javascript'>
//<![CDATA[
var DateCalendar;
function changeDate(d){
if (d == "") {
d = DateCalendar;
}
var da = d.split(' ');
day = "<strong class='date_day'>"+da[0]+"</strong>";
month = "<strong class='date_month'>"+da[1].slice(0,3)+"</strong>";
year = "<strong class='date_year'>"+da[2]+"</strong>";
document.write(month+day+year);
DateCalendar = d;
}
//]]>
</script> <b:if cond='data:blog.pageType != "static_page"'>
<style type='text/css'>
/* Calendar style date ----------------------------------------------- */
#Date {
background: transparent url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgVQXyz6kgGu8PcPr5hwbui86flVfOrjml6adoNOF2hApETIrJEUYgdM3XEyEakVsr0nB_bWYE6g94ujREdIw8y5P884-YblKjRH093K9ExidYRPYw9h_VmY-d65os62dv67C7EitToIj1/s1600/calendar07.png) no-repeat;
display: block;
width:60px;
height:60px;
float: left;
margin: 15px 2px 0 -108px;
padding: 0 0 8px 0px;
border: 0;
text-transform: uppercase;
}
.date_month {
display: block;
font-size: 15px;
font-weight:bold;
margin-top:-1px;
text-align:center;
color:#ffffff; /* Month's color */
}
.date_day {
display: block;
font-size: 28px;
font-weight:bold;
margin-top:-8px;
text-align:center;
color:#282828; /* Day's color */
}
.date_year {
display: block;
font-size: 10px;
margin-top:-8px;
text-align:center;
color:#282828; /* Year's color */
}
</style> </b:if>

儲存並更新頁面,文章旁邊就會有日曆式的日期囉。

沒有留言:

張貼留言