AngularJS global Date timezone offset

前端 未结 3 1650
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-20 12:01

I\'m looking to show dates relative to the users\' timezones.

My hope is that Angular has way to globally config the Date filter to do this—having to d

3条回答
  •  盖世英雄少女心
    2020-12-20 12:52

    From official documentation:

    Timezones

    Keep in mind that Angular datetime filter uses the time zone settings of the browser. So the same application will show different time information depending on the time zone settings of the computer that the application is running on. Neither Javascript nor Angular currently supports displaying the date with a timezone specified by the developer.

    http://docs.angularjs.org/guide/i18n

    A level 'higher' could be creating a wrapper type (AKA class, ...) with your function as constructor. This should be coded at the entry point of the application for being possible using it everywhere.

提交回复
热议问题