views:

32

answers:

0

I'm trying to learn asp.net MVC and got stuck on this. I have model that contains a DateTime value in UTC (OrderDate). I would like to add the local time offset (lto) to this OrderDate so that the client see OrderDate in his local time zone.

My approach is to use a Javascript as follows in the master page header:

function GetLocalOffset() { var now = new Date(); var offset = now.getTimezoneOffset(); document.getElementById("lto").value = offset; // updates a hidden field in the body }

... // calls the script in the master page ... ...

Now, how do I get the hidden field value (lto) to update my OrderDate in my the MVC model so that it is in local time zone when I return from the controller public ActionResult Index() method?