I have local date and UTC date.I need to convert the dates in a webpart according to browser timezone. I get the local browser time from javascript and store that in hidden variable.
<script type ="text/javascript" >
$(document).ready(getCLientDate);
function getCLientDate() {
var currentDate = new Date();
var hiddenDate = $("#<%= hdnDate.ClientID %>").val(currentDate);
// alert(hiddenDate);
}
The value in hidden variable is accessed on server side. Also i get the current UTC date from server side.
I have some existing dates which I need to convert without postback, hence the hidden value. Please guide on how to approach further.
public void ConvertEventDate(string localDate)
{
var CurrentlocaltimehdnDate = hdnDate.Value;
var currentUTCTime = DateTime.UtcNow;
row["Date"] = Convert.ToDateTime(item["EventDate"].ToString()).ToString("dd MMM yyyy");//getting from sql
//TO: How to convert the existing row["Date"]
}