The following returns time in microseconds, for example 4565212462.
alert( $.now() );
How do I convert it to a human readable time format,
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);
Using JavaScript native Date functions you can get hours, minutes and seconds as you want. If you wish to format date and time in particular way you may want to implement a method extending JavaScript Date prototype.
Here is one already implemented: https://github.com/jacwright/date.format
Try
console.log(
new Date().toLocaleString().slice(9, -3)
, new Date().toString().slice(16, -15)
);