How to get current time with jQuery

后端 未结 15 864
青春惊慌失措
青春惊慌失措 2020-12-07 08:10

The following returns time in microseconds, for example 4565212462.

alert( $.now() );

How do I convert it to a human readable time format,

15条回答
  •  庸人自扰
    2020-12-07 08:59

    You need to fetch all "numbers" manually

    like this:

    var currentdate = new Date(); 
        var datetime = "Now: " + currentdate.getDate() + "/"
                    + (currentdate.getMonth()+1)  + "/" 
                    + currentdate.getFullYear() + " @ "  
                    + currentdate.getHours() + ":"  
                    + currentdate.getMinutes() + ":" 
                    + currentdate.getSeconds();
    
    document.write(datetime);

提交回复
热议问题