如何在 JavaScript 获取当前日期?: A, u$ \5 E9 o% z K+ \: d5 c6 y
, T% j3 ^* e+ E. w" p. f4 e 解决方案: 7 @1 f, c! u, C 用于new Date()生成Date新对象包日期和时间的新对象。 ) @0 n6 A4 _- t/ g; A
var today = new Date();var dd = String(today.getDate()).padStart(二,0);var mm = String(today.getMonth() 1).padStart(二,0); //January is 0!var yyyy = today.getFullYear();today = mm '/' dd '/' yyyy;document.write(today);! F. D# N' a6 Q" r5 Q, ]2 m+ Y