javascript - 如何以字母显示日期 - Javascript --> innerhtml?
问题描述
var d = new Date();
var n = d.toLocaleDateString();
document.getElementById("dt").innerHTML = n;
<body>
<p id="dt" style="color: white; position: absolute; right: 25px; top: 5px; font-size: 25px;"></p>
</body>
解决方案
const options = {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric'
};
var d = new Date();
var n = d.toLocaleDateString('en-EN', options);
document.getElementById("dt").innerHTML = n;
<p id="dt"></p>
推荐阅读
- android - 错误:意外元素
在发现 - android - Android - 使用不同的按钮显示不同的布局
- java - 如何在 Tomcat 服务器上将 403 HttpStatus 设置为响应状态来呈现 jsp
- docker - 将 docker 日志输出到 mac 和 linux 上的文件中
- javascript - 如何在 JavaScript 中从 ArrayBuffer / DataView 读取 64 位整数
- r - 如何替换 ffdf 中的特定值?
- java - 为什么这个循环会打印 10-20 之间的所有值?我希望它打印可被 5 整除的值
- android - 如何在 Sceneform Android SDK 中将相机类型更改为正交?
- android - 如何使用 Json 使用 Mysql 的默认提示填充微调器
- wordpress - Woocommerce 3.4.4 - 产品缺货,更改产品库存状态时出错