うさのJavaScript講座 サンプル集 日付編
Top
>
サンプル集 日付編
> 現在日付を取得 (dates3)
クリップボードにコピー
サンプルを表示
//変数宣言 let today = new Date; //年月日を取得 let year = today.getFullYear(); let month = today.getMonth() + 1 < 10 ? "0" + (today.getMonth() + 1) : today.getMonth() + 1; let day = today.getDate() < 10 ? "0" + today.getDate() : today.getDate(); //表示 document.write(year+"/"+month+"/"+day);