我尝试转换像“hh:mm:ss”或“dd.mm.yyyy hh:mm:ss”这样的字符串,但我没有完成:( 像这样的代码:
public DateTime[] tarihSaat = new DateTime[documentRowCount]
string c = "27.12.2010 00:00:00"
tarihSaat[0] = DateTime.ParseExact(c, "dd.MM.yyyy hh:mm:ss", CultureInfo.InvariantCulture);
但它没有用..有什么建议吗?
最佳答案
你正在以正确的方式做所有事情,但也许你不需要hh
而是像这样HH
:
tarihSaat[0] = DateTime.ParseExact(c, "dd.MM.yyyy HH:mm:ss", CultureInfo.InvariantCulture);
hh
是 12 小时格式,看起来你是从 24 小时格式解析的,所以你需要 HH
。
关于c# - 字符串到日期时间 "hh:mm:ss"或 "dd.mm.yyyy hh:mm:ss"格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5584324/