Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pauljacobson/6b34c151c1d13a585e6febceae2fa1d4 to your computer and use it in GitHub Desktop.
Save pauljacobson/6b34c151c1d13a585e6febceae2fa1d4 to your computer and use it in GitHub Desktop.
This is a variation on my previous Real-Time Date-Time script
Date.prototype.dayName = function() {
const today = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
return today[this.getDay()];
}
function time() {
const now = new Date().toLocaleTimeString('en-GB');
const dateNow = new Date().toLocaleDateString('en-GB', {year: 'numeric', month: 'long', day: 'numeric'});
const todayNow = new Date().dayName();
document.querySelector('.clock').innerHTML = `<p>Today is ${todayNow}, ${dateNow}. The current time is ${now}.</p>`;
}
setInterval(time, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment