nandesuka
nandesuka

Reputation: 799

Create a UTC timestamp in ISO format

I need to create a UTC timestamp which is in ISO format

I tried:

new Date().getTime().toISOString();

But I get Uncaught TypeError: (intermediate value).getTime(...).toISOString is not a function

Upvotes: 0

Views: 138

Answers (2)

MKaplan
MKaplan

Reputation: 31

You can simply do new Date().toISOString();

Upvotes: 1

Ricky Mo
Ricky Mo

Reputation: 7618

getTime() returns the number of milliseconds since 1970, which is a number. toISOString() is a method of the Date object. you just want new Date().toISOString().

Upvotes: 0

Related Questions