最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

gwt - Set default TimeZone of the browser window in javascript - Stack Overflow

programmeradmin5浏览0评论

We are displaying schedules on our webpage which is build on GWT. Client system using different timezone from server and because of that, all the schedules were displaying wrong. Is there a way to set default time zone when we load the page? Like the way we do it in java:

TimeZone.setDefault(TimeZone.getTimeZone("Asia/Kolkata"));

Thanks!!!

We are displaying schedules on our webpage which is build on GWT. Client system using different timezone from server and because of that, all the schedules were displaying wrong. Is there a way to set default time zone when we load the page? Like the way we do it in java:

TimeZone.setDefault(TimeZone.getTimeZone("Asia/Kolkata"));

Thanks!!!

Share Improve this question asked Jul 11, 2012 at 11:15 ArunArun 1251 gold badge1 silver badge7 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

No, you can't set the timezone of Date objects in javascript. Usually you use only UTC and epoch-based timestamps.

Only when creating a Date from a string or from year, month etc. the local timezone will be used, you can only get the timezone offset.

Converting a timezone can only be done by re-setting the Hours of the Date object (example described here), creating a date which looks-like having an offset timezone but is just utc.

In case you are using moment.js for your dates, you can set the default timezone for all newly created moments with:

moment.tz.setDefault(String)

https://momentjs./timezone/docs/#/using-timezones/default-timezone/

发布评论

评论列表(0)

  1. 暂无评论