QQ:你认识这个日期格式吗? [英] QQ: Do you recognize this date format?

查看:84
本文介绍了QQ:你认识这个日期格式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在尝试重现一个特定文件,其日期存储如下:

2015-10-06T01:13:46.2784945 + 01:00

我可以将它解析为日期,但我现在需要把它放回去。 />


我在英国,所以我猜这个+01:00是BST?



有没有一种简单的方法从DateTime输出?



谢谢^ _ ^

Andy

Hi,

I'm trying to reproduce a particular file that has the date stored as follows:
2015-10-06T01:13:46.2784945+01:00
I can parse it as a date fine, but I now need to put it back.

I'm in the UK so I'm guessing that the +01:00 is BST?

Is there a simple way to output this from a DateTime?

Thanks ^_^
Andy

推荐答案

什么是源代码并不重要 - 问题是不同部分意味着什么...

我看到你有这种格式:

It is unimportant what was the source - the question is what the different parts means...
As I see you have this format:
[date]T[utc-time][timezone]





[utc-time]和[timezone]很简单,唯一的问题是[date]部分的日/月顺序...这可以通过查看一些样本数据来决定......



你有两个选择:



[utc-time] and [timezone] are simple, the only question is the day/month order in the [date] part...That's can be decided by looking on some sample data...

The two options you have are these:

YYYY-MM-DDTHH:MM:SS[+/-]HH:MM
YYYY-DD-MMTHH:MM:SS[+/-]HH:MM



请注意,SS也有小数点后的数字...


Notice, that SS has digits after the decimal point too...


Now.ToString("yyyy-MM-ddTHH:mm:ss.fffffffK")



或只是


or just

Now.ToString("o")





请参阅 https: //msdn.microsoft.com/en-us/library/az4se3k1.aspx [ ^ ]


使用此:



DateTime lDat = new DateTime (DatetimeValuetoBeConverted,DateTimeKind.Local);

Console.WriteLine(lDat.Kind);



而不是'DatetimeValuetoBeConverted',请使用你的日期时间值。
Use this :

DateTime lDat = new DateTime("DatetimeValuetoBeConverted", DateTimeKind.Local);
Console.WriteLine(lDat.Kind);

Instead of 'DatetimeValuetoBeConverted', use your datetime value.


这篇关于QQ:你认识这个日期格式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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