In Page Load add the following.
Page.ClientScript.RegisterStartupScript(this.GetType(), "onLoad",
"script language='javascript' type='text/javascript'>GetTimeZoneOffset();script");
//hdnLocalEndTime is the Hidden variable, which will hold the timezoneoffset.
//Javascript
function GetTimeZoneOffset()
{
var txtLocalEndTime=document.getElementById('hdnLocalEndTime');
var date = new Date()
var gmtHours = - date.getTimezoneOffset()/60;
txtLocalEndTime.value=gmtHours;
}
//Servermethod to calculate time in Browser timezone
string strEndDateTime="it should be the date and time in string format";
DateTime dt;
dt = Convert.ToDateTime(strEndDateTime);
txtEndTime.Text = Convert.ToString(dt.ToUniversalTime().AddHours(Convert.ToDouble(hdnLocalEndTime.Value)));
//txtEndTime.Text will display the time in local time zone
Tuesday, October 11, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment