-4
我想从这样的“28/10/2013 12:00:00 AM” 这样的长日期时间转换为像这样的“28/10/2013”这样的短日期格式Java脚本,但我不知道如何..使用javascript从日期时间转换为短日期格式
我尝试了以下功能,但它并没有正常工作
function dateToShort(myDate) {
var convertedStartDate = new Date(myDate);
var month = convertedStartDate.getMonth();
var day = convertedStartDate.getDay();
var year = convertedStartDate.getFullYear();
var shortStartDate = day+ "/" + month+ "/" + year;
return shortStartDate;
}
当我用这个参数“称之为” 28/10/2013" 它返回“5/4/2015”!!!
Regards
http://meta.stackexchange.com/questions/156810/stack-overflow-问题清单 – CodingGorilla
所有你需要的,你会在MDN上找到Date(日期)(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)。 – Sirko
http://momentjs.com,不客气 – naivists