document.getElementById('sunrise').innerHTML = (new Date(d.sys.sunrise * 1000)).toLocaleDateString()
The above code display date, how can I get date and time?
CodePudding user response:
you can just use
.toLocaleTimeString()
the same way it will display also the time
CodePudding user response:
You can just do this :
new Date().toLocaleString())
You have now the date and the time.
documentation here : toLocaleString() doc
CodePudding user response:
You can use .toTimeString()
to get the time in string.