Skip to content

Instantly share code, notes, and snippets.

@jsmithdev
Created March 19, 2017 19:58
Show Gist options
  • Save jsmithdev/6b5bbcf2718294afaf7fac8e26c7a6b0 to your computer and use it in GitHub Desktop.
Save jsmithdev/6b5bbcf2718294afaf7fac8e26c7a6b0 to your computer and use it in GitHub Desktop.
// LIVE @ https://jsfiddle.net/jamiesmith/q8aw51ry/
Date.prototype.today = function () {
return ((this.getDate() < 10)?"0":"") + this.getDate() +"/"+(((this.getMonth()+1) < 10)?"0":"") + (this.getMonth()+1) +"/"+ this.getFullYear();
}
Date.prototype.timeNow = function () {
return ((this.getHours() < 10)?"0":"") + this.getHours() +":"+ ((this.getMinutes() < 10)?"0":"") + this.getMinutes()
//+":"+ ((this.getSeconds() < 10)?"0":"") + this.getSeconds();
}
const newDate = new Date();
let d = newDate.timeNow() + " on " + newDate.today()
let speech = 'hey you, the time is '+d
const synth = window.speechSynthesis
let utterThis = new SpeechSynthesisUtterance(speech)
utterThis.lang = "en-US"
// uncomment below for Spanish
//utterThis.lang = "es"
synth.speak(utterThis)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment