获取当前时间

const fnDate = () => {
    const date = new Date();
    const year = date.getFullYear();
    const month = date.getMonth();
    const time=year+"-"+fnW((month));
    return time;
}

const fnW = (str) => {
    var num;
    str > 9 ? num = str : num = "0" + str;
    return num;
}

 

posted @ 2020-12-30 11:41  zhaoyzml  阅读(87)  评论(0编辑  收藏  举报