时间戳格式化

function formateDate(date,s,m){ //参数1:时间戳;参数2:年月日连接符;参数3:时分秒连接符
    year = date.getFullYear();
    month = date.getMonth()+1;
    day = date.getDate();
    hour = date.getHours();
    minute = date.getMinutes();
    second = date.getSeconds();
    return __date=year+s+month+s+day+s+' '+hour+m+minute+m+second;
};
let d = new Date();
let res=formateDate(d,'/',':');
console.log(res)
Solve problems in the most elegant way
原文地址:https://www.cnblogs.com/yanghmartin/p/martin.html