Date.prototype.getDate() - Local timeの日を返す
Date.prototype.getDate()は、インスタンスから、Local time(端末の時間設定)に従った「日」を取得するメソッドです。
概要
説明
Date.prototype.getDate ( )
Local timeにおける日付を表す1〜31の数値を返す。
デモ
Date.prototype.getDate()のデモです。
<!-- このコードは編集できます。 -->
<!DOCTYPE html>
<html>
<head>
<style>
body {
white-space: pre-wrap ;
}
</style>
</head>
<body>
<script>
/** try it! **/
var date = new Date( 2017, 4, 10 ) ;
var a = date.getDate() ;
/** try it! **/
var results = { a:a, } ;
for( var name in results ) {
console.log( name, results[name] ) ;
document.body.appendChild( new Text( name + " = " + JSON.stringify( results[name] ) + "\n" ) ) ;
}
</script>
</body>
</html>
サポート状況
Chrome | Firefox | Safari | Edge | IE | Opera | iOS Safari | Android |
---|---|---|---|---|---|---|---|
● | ● | ● | ● | ● | ● | ● | ● |
関連記事
- Date.now()
- Date.now()は、現在のミリ秒単位のUnix timestampを返すコンストラクタメソッドです。PHPのtime()などと同じく、ミリ秒ではなく秒で扱いたい場合は1000で割って下さい。
- Date
- Dateは日時を取り扱うための機能を備えたオブジェクトです。
- グローバルオブジェクト
- JavaScriptの各グローバルオブジェクト(組み込みオブジェクト)の使い方を、初心者向けにデモとサンプルコード付きでまとめています。各ブラウザのサポート状況など。
- Date.prototype.getFullYear()
- Date.prototype.getFullYear()は、インスタンスから、Local time(端末の時間設定)に従った「年」を取得するメソッドです。