获取当前时间

复制代码
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 @   zhaoyzml  阅读(89)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示