2

I create this date object:

var date = new Date(06, 2016);

When I open browser watch to check the created object I see this:

Mon Jun 06 2016 12:51:11 GMT+0300 (Jerusalem Daylight Time)

How can I simplify the above date object to this:

2016-06-06
alex
  • 438,662
  • 188
  • 837
  • 957
Michael
  • 11,410
  • 43
  • 120
  • 228
  • duplicate of http://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date I urge you to PLEASE do some research before posting, its utter laziness to add posts like this. – Alex Jun 06 '16 at 09:59

1 Answers1

5

You could do this...

date.toISOString().split("T")[0] // "2016-06-06"
alex
  • 438,662
  • 188
  • 837
  • 957