JavaScript toString() 方法

定义和用法

toString() 方法可把 Date 对象转换为字符串,并返回结果。

语法

dateObject.toString()

返回值

dateObject 的字符串表示,使用本地时间表示。

实例

在本例中,我们将把今天的日期转换为字符串:

<script type="text/javascript">

var d = new Date()
document.write (d.toString())

</script>

输出:

TIY

toString()
如何使用 toString() 把今天的日期转换为字符串。