1

我以 JSON 格式获取日期时间 -

"\/Date(1261413600000+0530)\/"

后面的代码中,我正在使用DataContractJsonSerializer.ReadObject方法来反序列化数据。

转换后的数据时间不正确。

如何从后面的代码中解析正确的 JSON 日期时间?

4

1 回答 1

0

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));
于 2010-03-12T18:17:54.897 回答