js获取当前日期事件(yyyy-MM-dd HH:mm:ss)

 function getDataTimeNow() {
            var nowstr = new Date();
            var datenow = nowstr.getFullYear() + "-"
                     + ((nowstr.getMonth() + 1) < 10 ? "0" : "") + (nowstr.getMonth() + 1) + "-"
                     + (nowstr.getDate() < 10 ? "0" : "") + nowstr.getDate()
                     + " "
                     + (nowstr.getHours() < 10 ? "0" : "") + nowstr.getHours() + ":"
                     + (nowstr.getMinutes() < 10 ? "0" : "") + nowstr.getMinutes() + ":"
                     + (nowstr.getSeconds() < 10 ? "0" : "") + nowstr.getSeconds();
            return datenow;

        }

  

原文地址:https://www.cnblogs.com/stevenjson/p/4105525.html