Javascript 设置日期无效,显示错误的时间
Javascript setting date not working, showing wrong hour
我想将日期和时间设置为 2016-05-11T00:00:00.000Z
var date = new Date(2016,4,12,0,0,0,0);
但不是显示日期 2016-05-11T00:00:00.000Z
而是给出日期 2016-05-11T19:00:00.000Z
我想要时间 00:00:00 但它给了 19:00:00
使用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]
我想将日期和时间设置为 2016-05-11T00:00:00.000Z
var date = new Date(2016,4,12,0,0,0,0);
但不是显示日期 2016-05-11T00:00:00.000Z
而是给出日期 2016-05-11T19:00:00.000Z
我想要时间 00:00:00 但它给了 19:00:00
使用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]