Put this javascript in Head tag, this script will create the cookie and then you can get this cookie in asp.net code file.
<script language="javascript" type="text/javascript">
var dt = new Date();
var tz = -dt.getTimezoneOffset();
setCookie("localtime", tz, 30);
function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}
Get Cookie value in ASPX.CS file
int localTime = 0;
HttpCookie cookieLT = HttpContext.Current.Request.Cookies["localtime"];
if (cookieLT != null)
{
localTime = Convert.ToInt32(cookieLT.Value);
}
This code will retunr the time difference bet the UTC and local time in minutes
<script language="javascript" type="text/javascript">
var dt = new Date();
var tz = -dt.getTimezoneOffset();
setCookie("localtime", tz, 30);
function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}
Get Cookie value in ASPX.CS file
int localTime = 0;
HttpCookie cookieLT = HttpContext.Current.Request.Cookies["localtime"];
if (cookieLT != null)
{
localTime = Convert.ToInt32(cookieLT.Value);
}
This code will retunr the time difference bet the UTC and local time in minutes