Coffeescript-date-todatestring
提供:Dev Guides
CoffeeScriptの日付-toDateString()
説明
- toDateString()*メソッドは、Dateオブジェクトの日付部分を人間が読める形式で返します。
構文
以下に、* toDateString()*メソッドの構文を示します。
Date.toDateString()
戻り値
Dateオブジェクトの日付部分を人間が読める形式で返します。
例
次の例は、CoffeeScriptでの* toDateString()メソッドの使用方法を示しています。 このコードを *date_todatestring.coffee という名前のファイルに保存します。
dt = new Date "February 19, 2016 23:15:00"
dt.toDateString()
console.log dt
- コマンドプロンプト*を開き、以下に示すように.coffeeファイルをコンパイルします。
c:\> coffee -c date_todatestring.coffee
コンパイル時に、次のJavaScriptが提供されます。
//Generated by CoffeeScript 1.10.0
(function() {
var dt;
dt = new Date("February 19, 2016 23:15:00");
dt.toDateString();
console.log(dt);
}).call(this);
次に、*コマンドプロンプト*を再度開き、以下に示すようにCoffeeScriptファイルを実行します。
c:\> coffee date_todatestring.coffee
CoffeeScriptファイルを実行すると、次の出力が生成されます。
Fri Feb 19 2016 23:15:00 GMT+0530 (India Standard Time)