LoginSignup
0
0

More than 3 years have passed since last update.

Javascript覚え書き

Posted at

日付の取得

今日の日付を取得

var today = new Date();

指定した日付を取得

var date = new Date( '2019/11/5 20:30' );

そこからさらに、すきな要素を取得

date.getFullYear(); // 日付の「年」を取得する(4桁)

date.getMonth();  // 日付の「月」を取得する(0 - 11)

date.getDate();    // 日付の「日」を取得する(1 - 31)

date.getDay();     // 日付の「曜日」を取得する(0 - 6)

date.getHours();   // 日付の「時」を取得する(0 - 23)

date.getMinutes(); //日付の「分」を取得する(0 - 59)

date.getSeconds(); // 日付の「秒」を取得する(0 - 59)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0