Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

how to get datetime javascript now

var currentdate = new Date();
var datetime = "Last Sync: " + currentdate.getDay() + "/" + currentdate.getMonth() 
+ "/" + currentdate.getFullYear() + " @ " 
+ currentdate.getHours() + ":" 
+ currentdate.getMinutes() + ":" + currentdate.getSeconds();
Comment

PREVIOUS NEXT
Code Example
Javascript :: how disabled react-select 
Javascript :: react native rename package name 
Javascript :: push elements to an object 
Javascript :: jquery ajax google api 
Javascript :: unordered list in react native 
Javascript :: jquery get select option attribute 
Javascript :: js hasownproperty multiple 
Javascript :: bootstrap js link not working 
Javascript :: object to json string android 
Javascript :: keyup addeventlistener 
Javascript :: jquery if div is empty 
Javascript :: timer.tc elixir 
Javascript :: can butterfly read english 
Javascript :: js get element by class 
Javascript :: update node js version ubuntu 
Javascript :: node js try catch 
Javascript :: jquery clone and append 
Javascript :: check if object is empty javascript 
Javascript :: use jetbrains mono in vscode 
Javascript :: how to use Node.js Client for Google Maps Services for geolocation 
Javascript :: how to get visitor ip address in javascript 
Javascript :: js nearest 100 
Javascript :: react useref file input 
Javascript :: Error: Could not symlink include/node/common.gypi /usr/local/include/node is not writable. 
Javascript :: delete slash commands discord.js 
Javascript :: node:internal/crypto/hash:67 this[kHandle] = new _Hash(algorithm, xofLen); 
Javascript :: MongoParseError: option usecreateindex is not supported 
Javascript :: getype js 
Javascript :: Codewars Convert a String to a Number! 
Javascript :: get all input values by class jquery 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =