这是我的jsfidde:http://jsfiddle.net/9SUqX/74/
原始代码:
var comments = [
{name:"Full Name",comment:"Quote",timestamp:1332045720},
];
$(document).ready(function() {
$("ul#feed").append("<li>\
<blockquote>"+comments[0].comment+"</blockquote>\
<cite>-"+comments[0].name+", "+comments[0].timestamp+" </cite>\
</li>");
});
答案 0 :(得分:0)
您需要将时间戳乘以1000(Javascript使用毫秒)并将其传递给日期:
var comments = [
{name:"Full Name",comment:"Quote",timestamp:1332045720},
];
$(document).ready(function() {
var d = new Date(comments[0].timestamp * 1000);
var date = [(d.getMonth() + 1), d.getDate(), d.getFullYear()].join("/");
$("ul#feed").append("<li>\
<blockquote>"+comments[0].comment+"</blockquote>\
<cite>-"+comments[0].name+", "+date+" </cite>\
</li>");
});