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); 7 v) V' E' W5 g0 n. L) \1 A9 D) X' c$ U
这将以 mm/dd/yyyy 格式为您提供今天的日期。8 Z, s9 Q$ j( [% u( E
只需更改today = mm `/ dd `/ yyyy;任何你想要的格式。