DateTime.Parse日期格式 [英] DateTime.Parse date format
本文介绍了DateTime.Parse日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个以字符串表示的日期
I have a date represented as a string thus
20130116154407
我为此调用了DateTime.Parse,但失败了。如何将其转换为DateTime?
I called DateTime.Parse on this but it failed. How can I convert this to a DateTime? Incidentally the timezone is CET.
EDIT
提供的解决方案非常有用,到目前为止,但似乎他们不支持24小时制,仍在寻找一种解决方案。
The solutions provided are very useful, so far but it seems they do not support 24 hour clocks, still looking for a solution that does.
编辑2
正确的格式为
DateTime.ParseExact(str, "yyyyMMddHHmmss", CultureInfo.InvariantCulture)
谢谢
Sachin
推荐答案
您需要指定格式:
DateTime.ParseExact(str, "yyyyMMddHHmmss", CultureInfo.InvariantCulture)
这篇关于DateTime.Parse日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文