Created
December 13, 2019 11:31
-
-
Save linkdigitaluk/7401b2348ef6653638a4e3726cdfb2da to your computer and use it in GitHub Desktop.
[Get Current Date and Time - JavaScript] #javascript #date #time
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
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