- CoffeeScript 教程
- CoffeeScript - 首頁
- CoffeeScript - 概述
- CoffeeScript - 環境
- CoffeeScript - 命令列實用工具
- CoffeeScript - 語法
- CoffeeScript - 資料型別
- CoffeeScript - 變數
- CoffeeScript - 運算子和別名
- CoffeeScript - 條件語句
- CoffeeScript - 迴圈
- CoffeeScript - 迴圈推導式
- CoffeeScript - 函式
- CoffeeScript 面向物件
- CoffeeScript - 字串
- CoffeeScript - 陣列
- CoffeeScript - 物件
- CoffeeScript - 範圍
- CoffeeScript - 星號
- CoffeeScript - 日期
- CoffeeScript - 數學
- CoffeeScript - 異常處理
- CoffeeScript - 正則表示式
- CoffeeScript - 類和繼承
- CoffeeScript 高階用法
- CoffeeScript - Ajax
- CoffeeScript - jQuery
- CoffeeScript - MongoDB
- CoffeeScript - SQLite
- CoffeeScript 有用資源
- CoffeeScript - 快速指南
- CoffeeScript - 有用資源
- CoffeeScript - 討論
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
coffeescript_date.htm
廣告