获取时间格式为YYYYMMDDHHMMSS

2019-07-22  本文已影响0人  轩_7ca0

         const nowstr = new Date();

          const 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();

console.log(datenow)

201907220000

上一篇下一篇

猜你喜欢

热点阅读