如何HEX值转换为日期时间的净 [英] How to convert HEX value to Datetime in .Net

查看:1168
本文介绍了如何HEX值转换为日期时间的净的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的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

这篇关于如何HEX值转换为日期时间的净的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆