-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,678
  • 4
  • 20
  • 33

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
  • 959,406
  • 173
  • 1,780
  • 1,769