totothegreat
totothegreat

Reputation: 1643

How do i get this kind of time format when "now" in javascript?

I have a need to put this kind of format when doing some action:

2014-11-19T10:07:25.000Z

Like when in a press of an action button, i need to alert the current time in the format above, in javascript, plain and simple...

What is the correct way to do so?

Upvotes: 2

Views: 53

Answers (1)

Leo
Leo

Reputation: 13838

This is the returned format of toISOString method of Date instance.

new Date().toISOString(); //"2014-12-06T08:10:55.713Z"

More on date and time iso, see MDN and wikipedia.

Upvotes: 4

Related Questions