如何将Twitter时间戳转换为DateTime? [英] How to Convert Twitter Timestamp to DateTime?
问题描述
我使用C#做Twitter客户端,并且使用C# Windows Presentation Foundation,我不知道如何更改Twitter提供给DateTime或UNIX时间戳的时间戳。
我知道它可能与Regex,但我从来没有找到解决方案。
有没有一些简单的方法来做这个我不知道?我想要转换的Twitter时间戳格式如下:
Fri Feb 11 23:45:15 +0000 2011
任何想法?
根据其他地方的示例,关于使用 ParseExact方法: p>
const string format =ddd MMM dd HH:mm:ss zzzz yyyy;
my_date = DateTime.ParseExact(dateString,format,CultureInfo.InvariantCulture);
I've been googling this for some time now, but I could never find an answer to my problem.
I'm making a Twitter client using C# and Windows Presentation Foundation, and I can't figure out how to change the timestamps that Twitter supplies to a DateTime or UNIX timestamp.
I know it's possible with Regex, but I never found a solution.
Is there some easy way to do this that I'm unaware of? The Twitter timestamp format that I'm trying to convert from looks like this:
Fri Feb 11 23:45:15 +0000 2011
Any ideas?
Based on a sample elsewhere, how about using the ParseExact method:
const string format = "ddd MMM dd HH:mm:ss zzzz yyyy";
my_date = DateTime.ParseExact(dateString, format, CultureInfo.InvariantCulture);
这篇关于如何将Twitter时间戳转换为DateTime?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!