- 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 日期 - toDateString()
说明
toDateString() 方法会以人类可读的形式,返回 Date 对象的日期部分。
语法
以下是 toDateString() 方法的语法。
Date.toDateString()
返回值
以人类可读的形式,返回 Date 对象的日期部分。
示例
以下示例演示了如何在 CoffeeScript 中使用 toDateString() 方法。请将此代码另存为名为 date_todatestring.coffee 的文件。
dt = new Date "February 19, 2016 23:15:00" dt.toDateString() console.log dt
打开 “命令提示符”,并按照以下步骤编译 .coffee 文件。
c:\> coffee -c date_todatestring.coffee
编译完后,系统会返回以下 JavaScript。
// Generated by CoffeeScript 1.10.0
(function() {
var dt;
dt = new Date("February 19, 2016 23:15:00");
dt.toDateString();
console.log(dt);
}).call(this);
现在,再次打开 “命令提示符”,并按照以下步骤运行 CoffeeScript 文件。
c:\> coffee date_todatestring.coffee
执行完后,CoffeeScript 文件会产生以下输出。
Fri Feb 19 2016 23:15:00 GMT+0530 (India Standard Time)
coffeescript_date.htm
广告