// time offset time as TimeSpan object
var offsetTime = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow).Ticks;
// time offset in minutes
var localtime_minutes = TimeSpan.FromTicks(offsetTime).TotalMinutes;
// add the offsetTime to the datetime recieved as UTC
ViewData["date"] = data.date.AddMinutes(localtime_minutes); |
[controller.cs]
namespace DatePickerSample.Controllers
{
public partial class DatePickerController : Controller
{
public ActionResult DatePickerFeatures()
{
System.Globalization.CultureInfo.CurrentCulture.ClearCachedData(); // clear the cache
TimeZone localZone = TimeZone.CurrentTimeZone; // time zone will be updated after clearing the cache
return View();
}
}
} |