Convert date to another timezone in JavaScript

后端 未结 24 3138
没有蜡笔的小新
没有蜡笔的小新 2020-11-21 04:45

I am looking for a function to convert date in one timezone to another.

It need two parameters,

  • date (in format \"2012/04/10 10:10:30 +0000\")
24条回答
  •  Happy的楠姐
    2020-11-21 05:32

    You can try this also for convert date timezone to India:

    var indianTimeZoneVal = new Date().toLocaleString('en-US', {timeZone: 'Asia/Kolkata'});
    var indainDateObj = new Date(indianTimeZoneVal);
    indainDateObj.setHours(indainDateObj.getHours() + 5);
    indainDateObj.setMinutes(indainDateObj.getMinutes() + 30);
    console.log(indainDateObj);
    

提交回复
热议问题