- 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 日期 - getUTCHours()
描述
getUTCHours() 方法会根据世界时返回指定日期中的小时。getUTCHours() 返回的值是 0 到 23 之间的整数。
语法
下面是 getUTCHours() 方法的语法。
Date.getUTCHours()
示例
下面的示例演示了如何在 CoffeeScript 中使用 getUTCHours() 方法。将此代码保存在一个名为 date_getutchours.coffee 的文件中。
dt = new Date() console.log "The UTC hours in the specified date is : " + dt.getUTCHours()
打开 命令提示符 并编译 .coffee 文件,如下所示。
c:\> coffee -c date_getutchours.coffee
编译完成后,它会生成以下 JavaScript。
// Generated by CoffeeScript 1.10.0
(function() {
var dt;
dt = new Date();
console.log("The UTC hours in the specified date is : " + dt.getUTCHours());
}).call(this);
现在,再次打开 命令提示符,并运行 CoffeeScript 文件,如下所示。
c:\> coffee date_getutchours.coffee
执行后,CoffeeScript 文件会生成以下输出。
The UTC hours in the specified date is : 17
coffeescript_date.htm
广告