CoffeeScript Date - getUTCMilliseconds()



描述

getUTCMilliseconds() 方法返回給定日期中的毫秒數,具體取決於通用時間。getUTCMilliseconds() 返回的值為 0 到 999 之間的整數。

語法

下面給出了 getUTCMilliseconds() 方法的語法。

Date.getUTCMilliseconds()

示例

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

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

開啟命令提示符,並按如下所示編譯 .coffee 檔案。

c:\> coffee -c date_getutcmilliseconds.coffee

在編譯時,它為您提供了以下 JavaScript。

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

  dt = new Date();

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

}).call(this);

現在,請再次開啟命令提示符,並按如下所示執行 CoffeeScript 檔案。

c:\> coffee date_getutcmilliseconds.coffee

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

The UTC milliseconds in the specified date is : 22
coffeescript_date.htm
廣告
© . All rights reserved.