I recommend XDate because it will save a lot of typing. Also, please do not use innerHTML, this is such a bad habit. I just did the same on the web page, and the key was to use the built-in javascript under the tag that you are updating, although you can also use "onload".
On the page, I add the tag and add some default data just because:
<p>Today is <span id="todays_date" style="font-style: italic;">November 1, 2015</span></p>
Moreover, below:
<script type="text/javascript"> var today = new XDate(); document.getElementById("todays_date").innerHTML = ""; document.getElementById("todays_date").appendChild(document.createTextNode(today.toString("MMMM d, yyyy"))); </script>
NB: I use innerHTML to quickly erase nested tags, rather than the recursive "delete all children" because it is in a different library and does not apply to this example.
See http://arshaw.com/xdate/
Richard Nunes
source share