How to get current time with jQuery

后端 未结 15 871
青春惊慌失措
青春惊慌失措 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 09:04

    jQuery.now() Returns: Number

    Description: Return a number representing the current time.

    This method does not accept any arguments.

    The $.now() method is a shorthand for the number returned by the expression (new Date).getTime().

    http://api.jquery.com/jQuery.now/

    It's simple to use Javascript:

    var d = new Date();
    var time = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
    console.log(time);
    

提交回复
热议问题