我做的一个显示xml文件的格式是这样的。但是我想做成“2012-9-6”这种格式的。。
下面是我代码
var beginIndex = (newsObjectDefault.pageIndex - 1) * newsObjectDefault.pageSize;请问先把要那个效果应该怎么改这个newsDateTime
var endIndex = (newsObjectDefault.pageIndex == sumPages && rest < newsObjectDefault.pageSize) ? (beginIndex + rest) : (beginIndex + newsObjectDefault.pageSize);
for (var i = beginIndex; i < endIndex; i++) {
var newsRow = news[i];
var newsDateTime = newsRow.date.substr(0, newsRow.date.indexOf(" "));
var newsTitle = newsRow.title;
newsType = getCmsCategory(newsRow.typename);
htmlContents += newsObjectDefault.newsFormat.replace("{0}", newsDateTime)
.replace("{1}", newsType)
.replace("{2}", newsRow.id)
.replace("{3}", newsTitle.length > 22 ? newsTitle.substr(0, 22) : newsTitle);
}
}
$(".box_news").empty().html(htmlContents);
javascript
Ajax
------解决方案--------------------
var newsDateTime = newsRow.date.substr(0, newsRow.date.indexOf(" "));
var arr = newsDateTime.split('/');
newsDateTime = arr[2] + '-' + arr[0] + '-' + arr[1];