美文网首页
js 获取当前时间(YYYY-mm-dd)

js 获取当前时间(YYYY-mm-dd)

作者: xiaolin_188 | 来源:发表于2016-12-05 10:04 被阅读0次
    function getNowFormatDate() {
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = '0' + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = '0' + strDate;
        }
        var currentdate = year + '-' + month + '-' + strDate;
        return currentdate;
    }
    

    相关文章

      网友评论

          本文标题:js 获取当前时间(YYYY-mm-dd)

          本文链接:https://www.haomeiwen.com/subject/abekmttx.html