我在表格中有这个日期:“2013-10-08T00:00:00” 我想以“dd.MM.yyyy”格式设置它
在数据表源中的我改变了这样:
{
"bSortable": true,
"mData": "PublishDate",
"bSearchable": true,
"mRender": function (data, type, row) {
if (data) {
debugger;
var re = /-?\d+/;
var m = re.exec(data);
var d = new Date(parseInt(m[0]));
var curr_date = d.getDate();
var curr_month = d.getMonth() + 1; //Months are zero based
var curr_year = d.getFullYear();
var formatedDate = curr_date + "/" + curr_month + "/" + curr_year + " " + d.getHours() + ":" + d.getMinutes();
return formatedDate;
}
else
return data
},
},
但它始终以1:1/1970年2:0
返回有什么建议吗?
答案 0 :(得分:4)
试试这个:
var m = data.split(/[T-]/);
var d = new Date(parseInt(m[0]),parseInt(m[1])-1,parseInt(m[2]));