如何HEX值转换为日期时间的净转换为、日期、时间、HEX

2023-09-04 03:43:02 作者:心有芊芊结

我有这样的5290F419这是对应于日期时间2013年11月23日二十三时59分45秒一个十六进制字符串。 我怎样才能做到这一点。NET中coding.I要转换的十六进制字符串日期时间与时区亚洲/加尔各答

I have a hex string like this "5290F419"It is corresponds to date time 2013-11-23 23:59:45. How can i do this in .Net coding.I want to convert hex string to datetime with timezone Asia/Calcutta

推荐答案

5290F419是1385231385这是星期六,2013年11月23号18点29分45秒格林尼治标准​​时间,这就是所谓的time_t

"5290F419" is 1385231385 which is Sat, 23 Nov 2013 18:29:45 GMT, it's called time_t

下面是基本的转换/ F#中以time_t的,code是pretty的简单,在C#中获得相同的

here is basic convert from / to time_t in F#, code is pretty simple to get same in C#

let seconds dt = Convert.ToInt32( (dt - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local ) ).TotalSeconds ) 
let fromseconds (seconds : float, dtk : DateTimeKind) = (new DateTime(1970, 1, 1, 0, 0, 0 , ( dtk : DateTimeKind ) )).AddSeconds(seconds)

所以我希望你可以从十六进制INT

so I hope you can get int from hex