将中国标准时间转成年-月-日格式

版权声明:创业:https://shop120085695.taobao.com https://blog.csdn.net/zxf1242652895/article/details/79065342
function formatTen(num) { 
return num > 9 ? (num + "") : ("0" + num); 
} 

function formatDate(date) { 
var year = date.getFullYear(); 
var month = date.getMonth() + 1; 
var day = date.getDate(); 
var hour = date.getHours(); 
var minute = date.getMinutes(); 
var second = date.getSeconds(); 
return year + "-" + formatTen(month) + "-" + formatTen(day); 
} 
var beformTime=Sun Oct 15 2017 00:00:00 GMT+0800 (中国标准时间);
var afterTime=formatDate(beformTime);
console.log(afterTime) 输出 2017-10-15

没有更多推荐了,返回首页