On my ASP.NET website I have a lot of pages with timestamps. I want to convert timestamps on-fly from the server time to the browser time. For that purpose I need to get client's timezone offset in code-behind.
What I tried is to set TimezoneOffset
cookie in the <head>
of every page using JavaScript. But it (obviously) not works when page is loaded in first time (and no cookie was set before).
Is there any elegant solution to convert dates from server to client time?
The only solution I see is to check TimezoneOffset
cookie in Page_Load
, then redirect to dummy page that will set this cookie, and then using JS redirect back to original page, but I do not like this solution.