-1

I'm trying to get todays date in the same format as my variable. The variable outputs the below:

2016-05-18T23:00:00.000Z

Where as this code below outputs the below:

1463152286532

 Date.now()

So the question is what do I have to do to Date.now() to make it the same format as my first blockquote.

Max Lynn
  • 1,738
  • 6
  • 22
  • 35

1 Answers1

1

The format you've shown at the top is the standard "ISO" format returned by Date#toISOString (spec | MDN). So:

new Date().toISOString();

Note: Date.now() returns a number, not a Date. It's the number of milliseconds since The Epoch (Jan 1st, 1970 at midnight UTC).

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875