如何解析DateTime字符串以支持24小时计时? [英] How to Parse a DateTime String to Support 24 hours timing?
本文介绍了如何解析DateTime字符串以支持24小时计时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试如下使用DateTime.TryParseExact:
I'm trying to use DateTime.TryParseExact as below:
DateTime modifiedSinceDateTime;
var succeeded = DateTime.TryParseExact(modifiedSince, "yyyy-MM-ddThh:mm:ss",
CultureInfo.InvariantCulture,
DateTimeStyles.None,
out modifiedSinceDateTime);
,但此DateTime值失败: 2013-06-06T22:41:20
,这表明我的日期时间格式不正确.我认为该模式不支持24小时计时格式,最多只能支持12小时
but it fails with this DateTime value: 2013-06-06T22:41:20
which suggests my date time pattern is not right. I think the pattern doesn't support 24 hours timing format, only up to 12 hours
正确的日期格式应该是什么样的?
What should be the correct date pattern like?
推荐答案
足够简单-将 hh
更改为 HH
.
hh
是12个小时的时钟, HH
24小时,如文档所示自定义日期和时间格式字符串.
这篇关于如何解析DateTime字符串以支持24小时计时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文