js 获取xxxx-xx-xx时间格式

function getdate() {
        var now = new Date(),
            y = now.getFullYear(),
            m = now.getMonth() + 1,
            d = now.getDate();
        return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) + " " + now.toTimeString().substr(0, 8);
    }

 

posted @ 2019-04-04 09:46  Redchar  阅读(510)  评论(0编辑  收藏  举报