我需要帮助将按钮输出的日期输出修改为仅为day name、month、day、year,而不是完整格式。我该如何缩短它?这是我所拥有的:
<h2 id="psu1">Spooky Candles</h2>
<button onclick="getElementById('psu1').innerHTML=Date()">
How soon can I get some delivered?
</button>
您可以尝试
<h2 id="psu1">Spooky Candles</h2>
<button onclick="getElementById('psu1').innerHTML=new Date().toLocaleDateString('en-US')">
How soon can I get some delivered?
</button>
你可以在这里找到更多信息https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString