Show Today’s Date with JavaScript

AddThis Social Bookmark Button

Want to display today’s date on your website or blog? This is super simple and written about everywhere but since I had to write this code today for another website I’ll publish it here in case it helps someone. I wrote one small js function and then when the page loads it loads the function using “body onload” call and the JavaScript function figured out today’s date and writes the date into a div on the page. I also added two lines that will change the format of the date, adding a zero to days and months that are under 10. Here’s the source code:

Between your <head> and </head> tags add the following JavaScript:

That’s it. Enjoy!

Popularity: 4%


Tags:


If you enjoyed this post, please consider to leave a comment.

Comments

No comments yet.

Leave a comment

(required)

(required)