SYNCERのロゴ
アイキャッチ画像

Date.prototype.getMonth() - Local timeの月を返す

Date.prototype.getMonth()は、インスタンスから、Local time(端末の時間設定)に従った「月」を取得するメソッドです。月は1からではなく、0から数える点にご注意下さい。

概要

名前
getMonth
所属
Date.prototype
仕様書
https://tc39.github.io/ecma262/#sec-date.prototype.getmonth

説明

Date.prototype.getMonth ( )

Local timeにおける月を表す0〜11の数値を返す。

デモ

Date.prototype.getMonth()のデモです。

<!-- このコードは編集できます。 -->

<!DOCTYPE html>
<html>
<head>
	<style>
body {
	white-space: pre-wrap ;
}
	</style>
</head>
<body>
<script>
/** try it! **/
var date = new Date( 2017, 4, 10, 12, 10, 30, 15 ) ;
var a = date.getMonth() ;
/** 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>

サポート状況

ChromeFirefoxSafariEdgeIEOperaiOS SafariAndroid
  • Twitterでシェア
  • Facebookでシェア
  • Google+でシェア
  • はてなブックマークでシェア
  • pocketに保存
  • LINEでシェア
更新履歴
2017年9月27日 (水)
コンテンツを公開しました。