时间戳转换YYYY-MM-DD格式

function getTime(dateStr){ var date = new Date(dateStr);

var Month = date.getMonth() + 1;

var Day = date.getDate();

var Y = date.getFullYear() + '-';

var M = Month < 10 ? '0' + Month + '-' : Month + '-';

var D = Day + 1 < 10 ? '0' + Day : Day;

return Y + M + D;

}

猜你喜欢

转载自blog.csdn.net/qq_38543537/article/details/80007764