[removed] Convert a UTC Date() object to the local timezone

前端 未结 4 764
醉酒成梦
醉酒成梦 2021-01-18 13:20

I have a Date() object that contains a UTC date, which I need converted to the users local timezone. Does anybody know how I could do this? :-)

4条回答
  •  爱一瞬间的悲伤
    2021-01-18 14:00

    I'm pretty sure it is done for you automatically.

    >>> d = new Date('Fri, 10 Jun 2011 19:49:23 UTC');
    Sat Jun 11 2011 07:49:23 GMT+1200 (New Zealand Standard Time)
    >>> d.getHours();
    7
    

提交回复
热议问题