我有一个快速的问题。.我正在使用名为“ clickfunnels”的网站构建器,并且它们不支持允许我通过网站显示当前日期的功能。但是,我可以向其中添加自定义html ...
话虽如此,我发现了一个古老的Stack Overflow问题,该问题非常接近于解决我的问题,但是此人希望当前日期显示+1或比当前日期显示的第二天。
这是我尝试过的编码,可以在网站上完美显示,我只需要显示当前日期即可,而不是+1。
有人可以给我一些编辑技巧吗?这将不胜感激!!!谢谢!
<span id="spanDate"></span>
<script type="text/javascript">
var months =
['January','February','March','April','May','June','July',
'August','September','October','November','December'];
var tomorrow = new Date();
tomorrow.setTime(tomorrow.getTime() + (1000*3600*24));
document.getElementById("spanDate").innerHTML =
months[tomorrow.getMonth()] + " " + tomorrow.getDate()+ ", " +
tomorrow.getFullYear();
</script>
答案 0 :(得分:1)
只需从明天删除(1000*3600*24)
。它增加了额外的一天
var months =
['January','February','March','April','May','June','July',
'August','September','October','November','December'];
var tomorrow = new Date();
tomorrow.setTime(tomorrow.getTime());
document.getElementById("spanDate").innerHTML =
months[tomorrow.getMonth()] + " " + tomorrow.getDate()+ ", " +
tomorrow.getFullYear();
<span id="spanDate"></span>
答案 1 :(得分:0)
只需删除setTime
行
<span id="spanDate"></span>
<script type="text/javascript">
var months =
['January','February','March','April','May','June','July',
'August','September','October','November','December'];
var tomorrow = new Date();
/* tomorrow.setTime(tomorrow.getTime() + (1000*3600*24)); */
document.getElementById("spanDate").innerHTML =
months[tomorrow.getMonth()] + " " + tomorrow.getDate()+ ", " +
tomorrow.getFullYear();
</script>