Project

General

Profile

Add today's date to your page

Added by Brian Schwartz over 8 years ago

You will need to use a little HTML code. In this example, I'm using H1 to center it, but you can use any style you prefer.

Here's what to insert in your markdown file:

<h1>
<script language = "JavaScript">
var now = new Date();
var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var monNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
document.write("Today is " + dayNames[now.getDay()] + " " + monNames[now.getMonth()] + " " + now.getDate() + ", " + now.getFullYear());
</script>
</h1>

If you want to add the work week:

Today is

<script>
Date.prototype.getWeek = function() {
var onejan = new Date(this.getFullYear(), 0, 1);
return Math.floor((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);
}
var weekNumber = (new Date()).getWeek();
var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
var now = new Date();
document.write(dayNames[now.getDay()] + " and we are in week " + weekNumber + ".");
</script>