Date.prototype.toString() - 文字列に変換する
Date.prototype.toString()は、インスタンスの日時を文字列に変換するメソッドです。
概要
説明
Date.prototype.toString ( )
文字列(例: Thu Sep 28 2017 16:11:42 GMT+0900 (JST))を返す。
デモ
Date.prototype.toString()のデモです。
<!-- このコードは編集できます。 -->
<!DOCTYPE html>
<html>
<head>
<style>
body {
white-space: pre-wrap ;
}
</style>
</head>
<body>
<script>
/** try it! **/
var date = new Date() ;
var a = date.toString() ;
var b = date.toLocaleString() ;
/** try it! **/
var results = { a:a, b:b, } ;
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 |
---|---|---|---|---|---|---|---|
● | ● | ● | ● | ● | ● | ● | ● |
関連記事
- String
- Stringは文字列を取り扱うための機能を備えたオブジェクトです。
- Window.open()
- open()は、Windowのメソッドです。新しいウィンドウを開きます。
- 先頭、末尾の文字を削除する
- 先頭、末尾の文字を削除します。
- Date
- Dateは日時を取り扱うための機能を備えたオブジェクトです。