Created
October 25, 2017 08:29
-
-
Save pauljacobson/6b34c151c1d13a585e6febceae2fa1d4 to your computer and use it in GitHub Desktop.
This is a variation on my previous Real-Time Date-Time script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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