Create a Date with a set timezone without using a string representation

前端 未结 23 1141
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 01:48

I have a web page with three dropdowns for day, month and year. If I use the JavaScript Date constructor that takes numbers, then I get a Date obje

23条回答
  •  情话喂你
    2020-11-22 02:11

    GMT -03:00 Example

    new Date(new Date()-3600*1000*3).toISOString();  // 2020-02-27T15:03:26.261Z
    

    Or even

    now  = new Date().getTime()-3600*1000*3; // 1582818380528
    data = new Date(now).toISOString();      // 2020-02-27T15:03:26.261Z
    

提交回复
热议问题