I have a date at client side, I am converting that date to millisecond there and passing the milliseconds to server side code and the converting that to again in date format, but the issue is in this process my date changes. Below is my scenario
JavaScript Date:
var myDate= Fri Apr 01 2011 05:00:00 GMT+0530 (India Standard Time) {}
//Converted to milliseconds via this code (new Date(myDate)).getTime()
Output: 1301700600000
Now I am passing the above string(1301700600000) to my server side code via ajax. Below is the server side code.
private void Test(string myDate)
{
long myDateMilliseconds=long.Parse(myDate);
var myDate = new DateTime(1970, 1, 1) + new TimeSpan(myDateMilliseconds*10000);
//Here the date becomes Date = {3/31/2011 12:00:00 AM}
}
i.e Fri Apr 01 2011 05:00:00 GMT+0530 is not equal to {3/31/2011 12:00:00 AM} Note the date and time difference.
May I know how there is difference coming between the dates which I passed and the date which I have produced at the server.