jsが現在の時刻を取得します:YYYY-MM-DD HH:MM:SS

VaRの nowDate = 新しい日付(); するvar年= nowDate.getFullYear(); 

 VaRの月= nowDate.getMonth()+ 1 < 10" 0 " +(nowDate.getMonth()+ 1 ):nowDate.getMonth() + 1 

 VaRの日= nowDate.getDate()< 10" 0 " + nowDate.getDate():nowDate.getDate(); 
  
  VaRの時間= nowDate.getHours()< 10" 0 " + nowDate.getHours():nowDate.getHours();
VAR分= nowDate.getMinutes()< 10" 0 " + nowDate.getMinutes():nowDate.getMinutes();
するvar秒= nowDate.getSeconds()< 10" 0 " + nowDate.getSeconds():nowDate.getSeconds(); 

 VAR関数datestr =年+ " - " +月+ " - " +日+ "  " +時間+ " " +分+ " " + 秒。
 console.log(関数datestr)。

これが結果です

 

 

私はHTML5とJSを有効にする、ちょっと、実際には、かなりのバックエンドを書くのが好き、それを変更したい、それを埋めます

おすすめ

転載: www.cnblogs.com/xbxxf/p/11238424.html