Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript get current time

var today = new Date();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
Comment

javascript current time

let date = new Date();
let now = `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
console.log(now)
Comment

current time in javascript

    new Date().toLocaleString();

>> "09/08/2014, 2:35:56 AM"
Comment

get current time in javascript

var d = new Date();
var n = d.toLocaleTimeString();
document.getElementById("timer").innnerHTML = n;
Comment

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'
})
Comment

javascript current date time

function getDateTime() {
        var now     = new Date(); 
        var year    = now.getFullYear();
        var month   = now.getMonth()+1; 
        var day     = now.getDate();
        var hour    = now.getHours();
        var minute  = now.getMinutes();
        var second  = now.getSeconds(); 
        if(month.toString().length == 1) {
             month = '0'+month;
        }
        if(day.toString().length == 1) {
             day = '0'+day;
        }   
        if(hour.toString().length == 1) {
             hour = '0'+hour;
        }
        if(minute.toString().length == 1) {
             minute = '0'+minute;
        }
        if(second.toString().length == 1) {
             second = '0'+second;
        }   
        var dateTime = year+'/'+month+'/'+day+' '+hour+':'+minute+':'+second;   
         return dateTime;
    }

    // example usage: realtime clock
    setInterval(function(){
        currentTime = getDateTime();
        document.getElementById("digital-clock").innerHTML = currentTime;
    }, 1000);
Comment

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"
Comment

javascript get current time

let today = new Date();
let time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript replace spaces with nbsp 
Javascript :: javascript change comma to dot 
Javascript :: kill all node process ubunut 
Javascript :: js set class 
Javascript :: jquery detect when a checkbox is checked 
Javascript :: jquery check a radio button 
Javascript :: jquery open a new tab 
Javascript :: wait for element javascript 
Javascript :: js explode equivalent 
Javascript :: javascript location href target _blank 
Javascript :: react native flatlist horizontal scroll 
Javascript :: eslint change max line length 
Javascript :: if str contains jquery 
Javascript :: js number 2 decimal places 
Javascript :: moment today date 
Javascript :: react js usehistory push and pass props 
Javascript :: jquery is numeric 
Javascript :: submit form through jquery by id 
Javascript :: how to install font-awesome 
Javascript :: kill node process windows 
Javascript :: angular for loop key value 
Javascript :: Unknown command: "create-react-app" 
Javascript :: how to get all elements with same class in javascript 
Javascript :: clear form in react 
Javascript :: how to get the value of radio button in jquery 
Javascript :: is email js 
Javascript :: js code to generate random base64 code 
Javascript :: camera helper three js 
Javascript :: Manifest 3 content security policy 
Javascript :: react native text area form 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =