I use telerik raddatepicker control to select a date.
I get the date value from the control, convert it into javascript Date object and then use getTime to get the total milliseconds:
var FromDate = $find("<%=fromDate.ClientID%>").get_dateInput().get_displayValue();
var FromDateMill = new Date(FromDate).getTime();
The date I choose is 6/4/2012 (us). when I print the result of new Date(FromDate) I get the correct date I chose.
In server side, I try to get datetime object using the milliseconds I got from the javascript so I use this code:
DateTime seventies = new DateTime(1970, 1, 1);
DateTime fromDate = seventies.AddMilliseconds(Convert.ToDouble(Reader["FromDateMill"]));
but when I print fromDate I get 6/3/2012 9:00:00 AM (a day before..). I checked and saw that the conversion toDouble returns the correct number of milliseconds as I got in the javascript.
Does anyone has an idea what am I doing wrong?
Thanks, Inbal.