2

I want to set date and time to 2016-05-11T00:00:00.000Z

var date = new Date(2016,4,12,0,0,0,0);

but instead of showing Date 2016-05-11T00:00:00.000Z its giving Date 2016-05-11T19:00:00.000Z

I want time 00:00:00 but its giving 19:00:00

Liam
  • 27,717
  • 28
  • 128
  • 190
  • It might be your time zone, see http://stackoverflow.com/questions/439630/how-do-you-create-a-javascript-date-object-with-a-set-timezone-without-using-a-s – SQL Hacks May 11 '16 at 10:07
  • showing where? How? Your code just creates a date object. It doesn't *"show"* it anywhere. Are you outputting it? If so how? – Liam May 11 '16 at 10:09

1 Answers1

6

Use Date.UTC:

Note: Where Date is called as a constructor with more than one argument, the specifed arguments represent local time. If UTC is desired, use new Date(Date.UTC(...)) with the same arguments. [Source]

Nina Scholz
  • 376,160
  • 25
  • 347
  • 392