Answers for "javascript current time and date"

19

javascript get current time

var today = new Date();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
Posted by: Guest on March-30-2020
8

javascript current date time

var today = new Date().toLocaleDateString(undefined, {
    day: '2-digit',
    month: '2-digit',
    year: 'numeric',
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit'
})
Posted by: Guest on April-07-2020
1

get current time in javascript

var d = new Date();
var n = d.toLocaleTimeString();
document.getElementById("timer").innnerHTML = n;
Posted by: Guest on April-24-2021
1

javascript get current time

var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));

// formats below assume the local time zone of the locale;
// America/Los_Angeles for the US

// US English uses 12-hour time with AM/PM
console.log(date.toLocaleTimeString('en-US'));
// "7:00:00 PM"

// British English uses 24-hour time without AM/PM
console.log(date.toLocaleTimeString('en-GB'));
// "03:00:00"
Posted by: Guest on July-10-2020

Code answers related to "javascript current time and date"

Code answers related to "Javascript"

Browse Popular Code Answers by Language