光辉飞翔

导航

 

toUTCString 方法

返回一个已被转换为字符串的,用全球标准时间 (UTC)表示的日期。

dateObj.toUTCString()

必选项 dateObj 参数为任意 Date 对象。

说明

toUTCString 方法返回一个 String 对象,此对象中包含了使用 UTC 惯例以一种方便易读的形式进行格式化的日期。

示例

下面这个例子说明了 toUTCString 方法的用法。

例子1:
function toUTCStrDemo(){    var d, s; //
声明变量。    d = new Date(); // 创建 Date 对象。    s = "Current setting is ";    s += d.toUTCString(); // 转换为 UTC 字符串。    return(s); // 返回 UTC 字符串。 }

输出:Current setting is Thu, 27 Sep 2012 07:13:06 GMT

例子2:
<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00")
document.write(born.toUTCString())
</script>
输出:Wed, 20 Jul 1983 17:15:00 GMT
posted on 2012-09-27 14:58  光辉飞翔  阅读(1248)  评论(0编辑  收藏  举报