Coffeescript-date-getutcfullyear
提供:Dev Guides
CoffeeScriptの日付-getUTCFullYear()
説明
- getUTCFullYear()*メソッドは、世界時に従って指定された日付の年を返します。 getUTCFullYear()によって返される値は、2000年(2008など)に準拠する絶対数です。
構文
以下に示すのは、* getUTCFullYear()*メソッドの構文です。
Date.getUTCFullYear()
例
次の例は、CoffeeScriptでの* getUTCFullYear()メソッドの使用方法を示しています。 このコードを *date_getutcfullyear.coffee という名前のファイルに保存します。
dt = new Date "February 19, 2016 23:15:25:22"
console.log "The UTC full year in the specified date is : " + dt.getFullYear()
- コマンドプロンプト*を開き、以下に示すように.coffeeファイルをコンパイルします。
c:\> coffee -c date_getutcfullyear.coffee
コンパイル時に、次のJavaScriptが提供されます。
//Generated by CoffeeScript 1.10.0
(function() {
var dt;
dt = new Date("February 19, 2016 23:15:25:22");
console.log("The UTC full year in the specified date is : " + dt.getFullYear());
}).call(this);
次に、*コマンドプロンプト*を再度開き、以下に示すようにCoffeeScriptファイルを実行します。
c:\> coffee date_getutcfullyear.coffee
CoffeeScriptファイルを実行すると、次の出力が生成されます。
The UTC full year in the specified date is : 2016