- 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 日期 - getDate()
说明
getDate() 方法根据当地时间返回指定日期的当月日期。getDate() 返回的值是在 1 到 31 之间的整数。
语法
以下是在 CoffeeScript 中 getDate() 方法的语法。
Date.getDate()
范例
以下范例展示如何使用 CoffeeScript 中的 getDate() 方法。将此代码保存到一个名为 date_getdate.coffee 的文件中。
dt = new Date "December 25, 1995 23:15:00" console.log "The day of the current date object is : " + dt.getDate()
打开 命令提示符 并按照下方所示编译 .coffee 文件。
c:\> coffee -c date_getdate.coffee
编译后,它会生成以下 JavaScript。
// Generated by CoffeeScript 1.10.0
(function() {
var dt;
dt = new Date("December 25, 1995 23:15:00");
console.log("The day of the current date object is : " + dt.getDate());
}).call(this);
然后,再次打开 命令提示符,并按照下方所示运行 CoffeeScript 文件。
c:\> coffee date_getdate.coffee
执行后,CoffeeScript 文件会产生以下输出。
The day in the current date object is : 25
coffeescript_date.htm
广告