CoffeeScript 日期 - getUTCSeconds()



簡介

getUTCSeconds() 方法根據世界標準時間返回指定日期中的秒數。getUTCSeconds() 返回的值在 0 到 59 之間的整數。

語法

以下是 getUTCSeconds() 方法的語法。

Date.getUTCSeconds()

示例

以下示例演示了 CoffeeScript 中 getUTCSeconds() 方法的使用方式。將此程式碼另存為名為 date_getutcseconds.coffee 的檔案。

dt = new Date()
console.log "The UTC seconds in the specified date is : " + dt.getUTCSeconds()

開啟 命令提示符 並按照以下方式編譯 .coffee 檔案。

c:\> coffee -c date_getutcseconds.coffee 

編譯後,會生成以下 JavaScript。

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

  dt = new Date();

  console.log("The UTC seconds in the specified date is : " + dt.getUTCSeconds());

}).call(this);

現在,再次開啟 命令提示符,並按以下方式執行 CoffeeScript 檔案。

c:\> coffee date_getutcseconds.coffee

執行後,CoffeeScript 檔案會生成以下輸出。

The UTC seconds in the specified date is : 12
coffeescript_date.htm
廣告