开发者

How are these numbers converted to a readable Date/Time string?

开发者 https://www.devze.com 2023-01-03 09:37 出处:网络
I have 2 XML files I\'m reading - one has a date/time attribute that\'s readable (ex. May 1, 2010 12:03:14 AM) and the other... not so much (ex. 1272686594492). Both files have the complicated date/ti

I have 2 XML files I'm reading - one has a date/time attribute that's readable (ex. May 1, 2010 12:03:14 AM) and the other... not so much (ex. 1272686594492). Both files have the complicated date/time format, but only the newer one has the readable version. I cannot figure out how to make the complicated version readable. Any ideas?

The numbers are in the pastbin below.

http://pastebin开发者_StackOverflow社区.com/HMLEAGhf

Thanks!


Looks like what you have is the number of milliseconds from midnight, January 1st 1970 (which is kind of like UNIX time, except it's in milliseconds, not seconds). For example:

long l = 1272740342854;
DateTime dt = new DateTime(1970, 1, 1).AddMilliseconds(l);
Console.WriteLine(dt);

When I plug that in, it's actually a couple of hours off so I guess there must be some kind of timezone offset applied as well.


My guess is the number represents the seconds since 1st of january 1970

so 1276648174733 = June 16, 2010 00:29:34

http://www.mbari.org/staff/rich/utccalc.htm

0

精彩评论

暂无评论...
验证码 换一张
取 消