jquerydatetimetimeunix-timestampmicrotime

How to get current time with jQuery


The following returns time in microseconds, for example 4565212462.

alert( $.now() );

How do I convert it to a human readable time format, such as (hours:minutes:seconds)?


Solution

  • You may try like this:

    new Date($.now());
    

    Also using Javascript you can do like this:

    var dt = new Date();
    var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
    document.write(time);