A student class has a property called birthday. My web Server is in Beijing (UTC+8), and when I get data from the server in JSON format, the birthday property always reduces 8 hours to the original date, How can I correct this? I am also in Beijing and I add 8 hours to all birthday properties, but if I am in another timezone or the web server is not in Beijing then I have to add other hours manually.
On the web server, here's my code:
return Json(student);
The codes that get the data:
var studentReader= new StreamReader(Request.InputStream);
var student= JsonHelper.FromJson<Student>(studentReader.ReadToEnd());
The JsonHelper class:
public static T FromJson<T>(this string json)
{
return JsonConvert.DeserializeObject<T>(json);
}