Created
August 11, 2017 06:16
-
-
Save gotoark/ef928497a885299c732d01b81870415f to your computer and use it in GitHub Desktop.
Get Current Time in Javascript Original Source : https://stackoverflow.com/a/18229123/5740760
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 checkTime(i) { | |
if (i < 10) { | |
i = "0" + i; | |
} | |
return i; | |
} | |
function startTime() { | |
var today = new Date(); | |
var h = today.getHours(); | |
var m = today.getMinutes(); | |
var s = today.getSeconds(); | |
var ms = today.getMilliseconds(); | |
// add a zero in front of numbers<10 | |
m = checkTime(m); | |
s = checkTime(s); | |
ms=checkTime(ms); | |
return h + ":" + m + ":" + s+ ":" +ms; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment