DateTime.Parse DD / MM / YYYY 24小时时钟

DateTime.Parse DD / MM / YYYY 24小时时钟

问题描述:

DateTime.Parse上失败

DateTime.Parse fails on

 15/08/2000 16:58

有什么想法?

我需要解析的日期,并得到一些国际化。

I need to parse dates and get some international.

DD / MM / YYYY不会翻牌为24小时制

DD/MM/YYYY will not flop to 24 hour clock

MM / DD / YYYY接受24小时时钟

MM/DD/YYYY will accept 24 hour clock

15/08/2000下午4时58分将解析

15/08/2000 4:58 PM will parse

从基比的答案我看了看使用其他文化。 我用正则表达式来确定它是否是DD / MM,如果是用文化FR-FR。

From the Kibbee answer I looked at using other cultures. I use Regex to determine if it is dd/MM and if so use culture fr-FR.

尝试DateTime.ParseExact()$c$c>:

var result = DateTime.ParseExact(dateString,
                                 "dd/MM/yyyy HH:mm",
                                 new CultureInfo("en-US"));