我需要以 2014-11-04 格式将日期显示为“yy mm dd”
目前,我的脚本仍然显示
2014 年 11 月 4 日星期二 00:00:00 GMT+0200(埃及标准时间)
$(document).ready(function() {
var userDate = '04.11.2014';
from = userDate.split(".");
f = new Date(from[2], from[1] - 1, from[0]);
console.log(f);
});
您可以使用日期对象的方法来构造它
var date = new Date(userDate),
yr = date.getFullYear(),
month = date.getMonth() < 10 ? '0' + date.getMonth() : date.getMonth(),
day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate(),
newDate = yr + '-' + month + '-' + day;
console.log(newDate);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)