1var today = new Date();
2var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
3
1var today = new Date().toLocaleDateString(undefined, {
2 day: '2-digit',
3 month: '2-digit',
4 year: 'numeric',
5 hour: '2-digit',
6 minute: '2-digit',
7 second: '2-digit'
8})
9
1var d = new Date();
2var n = d.toLocaleTimeString();
3document.getElementById("timer").innnerHTML = n;
1var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
2
3// formats below assume the local time zone of the locale;
4// America/Los_Angeles for the US
5
6// US English uses 12-hour time with AM/PM
7console.log(date.toLocaleTimeString('en-US'));
8// "7:00:00 PM"
9
10// British English uses 24-hour time without AM/PM
11console.log(date.toLocaleTimeString('en-GB'));
12// "03:00:00"
1let today = new Date();
2let time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();