作者: 文章来源:
本文原地址:https://www.mimiwuqi.com/webqianduan/196116.html
目录文章目录toDateString() 方法可把 Date 对象的日期部分转换为字符串,并返回结果。
Date.toDateString()
| Type | 描述 |
|---|---|
| String | 日期作为字符串输出。 |
所有主要浏览器都支持 toDateString() 方法。
把 Date 对象的日期部分转换为可读字符串:
<p id="demo">单击按钮以字符串显示日期</p>
<button onclick="myFunction()">点我</button>
<script>
function myFunction(){
var d = new Date();
var x = document.getElementById("demo");
x.innerHTML=d.toDateString();
}
</script>
更多 建站教程 请访问 https://www.mimiwuqi.com/webqianduan/