「JavaScript/Date」の版間の差分

削除された内容 追加された内容
Ef3 (トーク | 投稿記録)
加筆
Ef3 (トーク | 投稿記録)
→‎協定世界時のメソッド: <source lang=javascript>
102 行
==== Date.prototype.getUTCFullYear() ====
協定世界時での年を取得する。
<source lang=javascript>
console.log(new Date().getUTCFullYear()); // 2021
</source>
 
==== Date.prototype.getUTCMonth() ====
協定世界時での月(0-11)を取得する。
<source lang=javascript>
console.log(new Date().getUTCMonth()); // 5
</source>
 
==== Date.prototype.getUTCDate() ====
協定世界時での日付を取得する(0(1-11)31)
<source lang=javascript>
console.log(new Date().getUTCDate()); // 27
</source>
 
==== Date.prototype.getUTCDay() ====
協定世界時での週を取得する。0が日曜日
<source lang=javascript>
console.log("日月火水木金土"[new Date().getUTCDay()]); // 日
</source>
 
==== Date.prototype.getUTCMinutes() ====
協定世界時での取得する。
<source lang=javascript>
console.log(new Date().getUTCMinutes()); // 49
</source>
 
==== Date.prototype.getUTCSeconds() ====
協定世界時での秒を取得する。
<source lang=javascript>
console.log(new Date().getUTCSeconds()); // 15
</source>
 
==== Date.prototype.getUTCMilliseconds() ====
協定世界時での1秒未満をミリ秒単位に取得する。
<source lang=javascript>
console.log(new Date().getUTCMilliseconds()); // 555
</source>
 
==== Date.prototype.setUTCFullYear(year [, month [, date]]) ====