Javascript Date functions

by AlexJsh02

HTML

<p id="demo"></p>

CSS

table {
  border-collapse: collapse;
}

table, th, td {
  border: 1px solid black;
}

td {
  padding: 4px;
}

td:nth-child(1) {  
  /* your stuff here */
  /*padding-right: 1px;*/
  white-space: normal;
}

JavaScript

// javascript days
var strOut = "<table width='100%' border='1'><tbody>";
var d = new Date();
strOut += "<tr><td>" + d.getDate() + "</td><td> - getDate()	Returns the day of the month (from 1-31)</td></tr>";
var weekdays = ["Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday"];
strOut += "<tr><td>" + (weekdays[d.getDay()]).substr(0, 1) + "</td><td> - getDay() Returns the day of the week (from 0-6)</td></tr>";
strOut += "<tr><td>" + d.getFullYear().toString().padEnd(20, ' ') + "</td><td> - getFullYear() Returns the year (four digits)</td></tr>";
strOut += "<tr><td>" + d.getHours().toString().padEnd(20, ' ') + "</td><td> - getHours() Returns the hour (from 0-23)</td></tr>";
strOut += "<tr><td>" + d.getMilliseconds().toString().padEnd(20, ' ') + "</td><td> - getMilliseconds() Returns the milliseconds (from 0-999)</td></tr>";
strOut += "<tr><td>" + d.getMinutes() + "</td><td> - getMinutes() Returns the minutes (from 0-59)</td></tr>";
strOut += "<tr><td>" + d.getMonth() + "</td><td> - getMonth() Returns the month (from 0-11)</td></tr>";
strOut += "<tr><td>" + d.getSeconds() + "</td><td> - getSeconds() Returns the seconds (from 0-59)</td></tr>";
strOut += "<tr><td>" + d.getTime() + "</td><td> - getTime() Returns the number of milliseconds since midnight Jan 1, 1970</td></tr>";
strOut += "<tr><td>" + d.getTimezoneOffset() + "</td><td> - getTimezoneOffset() Returns the time difference between UTC time and local time, in minutes</td></tr>";
strOut += "<tr><td>" + d.getUTCDate() + "</td><td> - getUTCDate() Returns the day of the month, according to universal time (from 1-31)</td></tr>";
strOut += "<tr><td>" + d.getUTCDay() + "</td><td> - getUTCDay() Returns the day of the week, according to universal time (from 0-6)</td></tr>";
strOut += "<tr><td>" + d.getUTCFullYear() + "</td><td> - getUTCFullYear() Returns the year, according to universal time (four digits)</td></tr>";
strOut += "<tr><td>" + d.getUTCHours() + "</td><td> - getUTCHours() Returns the hour,...