Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js datetime now

 var d = Date(Date.now());
 a = d.toString()
 
  // Printing the current date                   
  document.write("The current date is: " + a)
  // The current date is: Fri Jun 22 2018 10:54:33 
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

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 :: html add class 
Javascript :: nuxt input mask 
Javascript :: write html in javascript 
Javascript :: jquery to br 
Javascript :: javascript map Removing Elements 
Javascript :: eject expo app to android and react native 
Javascript :: toastr.js notification for laravel 
Javascript :: how to push at top of array 
Javascript :: append to array js 
Javascript :: npx create-react-app current folder 
Javascript :: js how to print 
Javascript :: install react router dom 
Javascript :: nuxt router push 
Javascript :: delete from array based on value javascript 
Javascript :: allow only numerics and few alphabets in input type js 
Javascript :: Axios FormData / not JSON 
Javascript :: get authorization header javascript in my page 
Javascript :: get n number of elements from array javascript 
Javascript :: check all values from keys in object js 
Javascript :: html javascript type 
Javascript :: javascript string comma seprated price to int 
Javascript :: gulp runSequence 
Javascript :: console.time 
Javascript :: Two different lockfiles found: package-lock.json and yarn.lock 
Javascript :: object.keys 
Javascript :: Html2Canvas screenshot and download 
Javascript :: Select options of Select2 control based on values using Jquery 
Javascript :: javascript alert random word 
Javascript :: javascript math.pow 
Javascript :: Without using a new array or the reverse() method to Reverse an Array 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =