Skip to content

Instantly share code, notes, and snippets.

@linkdigitaluk
Created December 13, 2019 11:31
Show Gist options
  • Save linkdigitaluk/7401b2348ef6653638a4e3726cdfb2da to your computer and use it in GitHub Desktop.
Save linkdigitaluk/7401b2348ef6653638a4e3726cdfb2da to your computer and use it in GitHub Desktop.
[Get Current Date and Time - JavaScript] #javascript #date #time
function getDateTimeNow() {
var now = new Date();
return now.getDate() + '/' + (now.getMonth()+1) + '/' + now.getFullYear() + ' - ' + now.getHours() + ':' + now.getMinutes();
//returns "13/12/2019 - 11:26"
//NOTE: now.getMonth() is zero indexed (January is 0) so plus one to make it human friendly.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment