简体   繁体   中英

How get client timezone offset in spring controller without using cookie?

I'm trying to show dates on page, now server time is shown, the way I found is set cookie value in browser and use it in controller, but first time page is loading cookie value isn't settled. The only possible way I see is use ajax, Is there any way get timezone offset in controller without using cookie?

Sorry but there is really no way of getting timezone offset on the server side unless you explicitly pass it from the client. A possible work around is on the server side pass all your dates to the client in some standard timezone (probably GMT) then use javascript to localize the page to the right timezone.

A library I have used in the past that makes these timzones manipulations much easier is called moment.js but it is not necessary for you to use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM