C#中 - 如何时间戳转换为日期? [英] c# - How to convert Timestamp to Date?
本文介绍了C#中 - 如何时间戳转换为日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是从XML document.Now越来越时间戳,我想时间戳转换为日期格式(13月13)
I'm getting timestamp from xml document.Now, I want to convert Timestamp to Date format(13-May-13)
XmlNodeList cNodes = xncomment.SelectNodes("comment");
foreach (XmlNode node in cNodes)
{
//I'm getting this "1372061224000" in comment-date
string comment_date = node["creation-timestamp"].InnerText;
}
任何想法?先谢谢了。
Any ideas? Thanks in advance.
推荐答案
由于这看起来像一个Java时间戳,只需使用如下:
Given that this looks like a Java timestamp, simply use below:
var dt = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Math.Round(1372061224000 / 1000d)).ToLocalTime();
Console.WriteLine(dt); // Prints: 6/24/2013 10:07:04 AM
这篇关于C#中 - 如何时间戳转换为日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文