Coffeescript-date-totimestring

提供:Dev Guides
移動先:案内検索

CoffeeScriptの日付-toTimeString()

説明

  • toTimeString()*メソッドは、Dateオブジェクトの時間部分を人間が読める形式で返します。

構文

以下は、* toTimeString()*メソッドの構文です。

Date.toTimeString()

戻り値

Dateオブジェクトの時間部分を人間が読める形式で返します。

次の例は、CoffeeScriptでの* toTimeString()メソッドの使用方法を示しています。 このコードを *date_totimestring .coffee という名前のファイルに保存します。

dt = new Date(1993, 6, 28, 14, 39, 7);
console.log dt.toTimeString()
  • コマンドプロンプト*を開き、以下に示すように.coffeeファイルをコンパイルします。
c:\> coffee -c date_totimestring .coffee

コンパイル時に、次のJavaScriptが提供されます。

//Generated by CoffeeScript 1.10.0
(function() {
  var dt;

  dt = new Date(1993, 6, 28, 14, 39, 7);

  console.log(dt.toTimeString());

}).call(this);

次に、*コマンドプロンプト*を再度開き、以下に示すようにCoffeeScriptファイルを実行します。

c:\> coffee date_totimestring.coffee

CoffeeScriptファイルを実行すると、次の出力が生成されます。

14:39:07 GMT+0530 (India Standard Time)