$.now()
gives me the time as miliseconds. I need to show it something like hh:mm:ss
How can I do that in Jquery?
new Date().toString().split(' ')[4]
or
new Date().toString().match(/\d{2}:\d{2}:\d{2}/)[0]
The toString
method is basically an alias for toLocaleString
in most implementations. This will return the time in the user's timezone as opposed to assuming UTC by using milliseconds if you use getTime
(if you use getMilliseconds
you should be OK) or toUTCString
.