首页 > 解决方案 > 如何以字母显示日期 - 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>

标签: javascripthtmlcss

解决方案


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>


推荐阅读