Reputation: 3
I have a quick question.. I am using website builder called 'clickfunnels', and they dont support feature that would allow me to display current date via website. But, I can add custom html to it...
With that said, I found an old Stack Overflow question which is very close to fixing my problem, but this person wanted the current date to show +1 or the next day than the current date.
Here is the coding I tried, which works perfect on the website, I just need it to show the current date and not +1.
Can anyone please give me some tips on editing this? It would be greatly appreciated!!! Thank You!
<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>
Upvotes: 0
Views: 1608
Reputation: 12152
Just remove (1000*3600*24)
from tomorrow. It is adding extra day
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>
Upvotes: 1
Reputation: 946
Just remove the setTime
line
<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>
Upvotes: 0