目录

toUTCString()

描述 (Description)

toUTCString()方法以人类可读的形式返回Date对象的时间部分。

语法 (Syntax)

下面给出了toUTCString()方法的语法。

Date.toUTCString()

返回值 (Return Value)

使用通用时间约定将转换后的日期返回到字符串。

例子 (Example)

以下示例演示了CoffeeScript中toUTCString()方法的用法。 将此代码保存在名为date_toutcstring.coffee的文件中。

dt = new Date(1993, 6, 28, 14, 39, 7);
console.log dt.toUTCString()

打开command prompt并编译.coffee文件,如下所示。

c:\> coffee -c date_toutcstring.coffee

在编译时,它为您提供以下JavaScript。

// Generated by CoffeeScript 1.10.0
(function() {
  var dt;
  dt = new Date(1993, 6, 28, 14, 39, 7);
  console.log(dt.toUTCString());
}).call(this);

现在,再次打开command prompt ,然后运行CoffeeScript文件,如下所示。

c:\> coffee date_toutcstring.coffee

执行时,CoffeeScript文件生成以下输出。

Wed, 28 Jul 1993 09:09:07 GMT
↑回到顶部↑
WIKI教程 @2018