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
  • 479,566
  • 201
  • 878
  • 984
Michael
  • 13,950
  • 57
  • 145
  • 288
  • 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. – Halfpint Jun 06 '16 at 09:59

1 Answers1

6

You could do this...

date.toISOString().split("T")[0] // "2016-06-06"
alex
  • 479,566
  • 201
  • 878
  • 984