Can I make the ASP.Net website display the time in a specific time zone?

I have a client request that is always displayed in the Pacific Time Zone, regardless of the client settings. I would like to avoid a scenario where I need to call a function for each time display, and instead one point where I can make a switch.

I think an ordinary culture could do the trick, but I wanted to ask before heading to a potentially dead end (or skipping something is trivially easy).

+3
source share
3 answers

You can use TimeZone.GetUTCOffset()andDateTime.UtcNow()

UTC , .

,

Dan

+4

If you save your time in UTC, you can easily convert whatever you want. Michael Brumm has some pretty old code that can help you with custom TimeZone. Hard offset coding will delay you when the DST starts up.

Note. I have not used this code on Michael's website.

http://www.michaelbrumm.com/simpletimezone.html

0
source

Source: https://habr.com/ru/post/1740001/


All Articles