Last active
March 11, 2021 00:00
-
-
Save dyazincahya/fed44e1d9705cf148e2a7d8fc81163d5 to your computer and use it in GitHub Desktop.
Get current date and time in Javascript
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
var d = new Date(); | |
var p = d.getFullYear(), | |
q = d.getMonth()+1, | |
r = d.getDate(), | |
s = d.getHours(), | |
t = d.getMinutes(), | |
u = d.getSeconds(); | |
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], | |
monthName = months[d.getMonth()]; | |
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], | |
dayName = days[d.getDay()]; | |
var result = dayName + ", " + r+"/"+monthName+"/"+p+" "+s+":"+t+":"+u; | |
// RESULT WHEN THIS CODE RUNNING | |
// "Thursday, 11/March/2021 6:56:3" | |
console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment