0

示例代码:

var postdate = entry.published.$t;
var month1 = [1,2,3,4,5,6,7,8,9,10,11,12];
var month2 = ["Jan","Feb","Mar","Apr","Mey","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
var d = postdate.split("-")[2].substring(0,2);
var m = postdate.split("-")[1];
var y = postdate.split("-")[0];
for(var u2=0; u2<month1.length; u2++){ if(parseInt(m)==month1[u2]){ m=month2[u2]; break;}}
var daystr = (showPostDate) ? '' + m + ' ' + d + ', ' + y + '' : "";
var item = '' + daystr + '';

发布日期的最终产品 = 2013 年 2 月 17 日

我想日期格式 = 2013 年 2 月 17 日星期六

var daynames = ["Monday","Tuesday", ... "Sunday"];
4

1 回答 1

0

如果需要格式化。您可以使用发布日期来创建 Date 对象。像这样:

var d = new Date(2013,2,17);

并使用 d 值创建您自己的日期:(https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date)。请参阅链接底部的示例。

使用以下内容获取日期并从数组中检索:

getDay
Returns the day of the week (0-6) for the specified date according to local time.

像这样:

var day = ["星期一", "星期二", ....];
console.log(day[d.getDay()]);

于 2013-02-17T03:44:39.547 回答