我以 JSON 格式获取日期时间 -
"\/Date(1261413600000+0530)\/"
从后面的代码中,我正在使用DataContractJsonSerializer.ReadObject
方法来反序列化数据。
转换后的数据时间不正确。
如何从后面的代码中解析正确的 JSON 日期时间?
You can use a regular expression to get the number which is the number of ticks since 1/1/1970. Then you can get the date using the following:
DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
DateTime dt = unixEpoch.AddSeconds(Convert.ToDouble(ticks));