How to get the time zone id (ex.: Central Standard Time) of the client machine in asp.net mvc?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- MVC-Routing,Why i can not ignore defaults,The matc
- void before promise syntax
- Keeping track of variable instances
That information is not sent to the server, so there is not trivial way to do it. One option would be to look up the IP in a Geolocation Database. http://www.ip2location.com/ is one.
You can also do a ajax postback using the javascript Date.getTimezoneOffset().
and store this in the session or with the user data.
If you have troubles showing time on the client side then you can do the following I wrote an extension to DateTime class that does conversion for me
then I've added a javascript file and let momentjs handle the conversion on the client side
It will have to be done on the Javascript side, and post that value in a hidden field back to the server. Look into the Date.getTimezoneOffset().