If you're sure that the date that comes from the server is valid, a simple RegExp can help you to change the format:(如果您确定来自服务器的日期有效,则简单的RegExp可以帮助您更改格式:)
function formatDate (input) {
var datePart = input.match(/d+/g),
year = datePart[0].substring(2), // get only two digits
month = datePart[1], day = datePart[2];
return day+'/'+month+'/'+year;
}
formatDate ('2010/01/18'); // "18/01/10"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…