DateTime.TryParseExact not working with expected string

后端 未结 2 1389
广开言路
广开言路 2021-01-26 11:25

Hi I have the following method and I\'m passing it the value \"07 Jan 2014 13:48:46\" and from what I understand the TryParseExact should be matching the format \"dd MMM yyyy hh

相关标签:
2条回答
  • 2021-01-26 11:51

    Because none of your format have 24-hour clock.

    hh specifier is for 01 to 12. It doesn't have 13 as an hour.

    Use HH specifier instead which is for 00 to 23.

    For more information, take a look at;

    • Custom Date and Time Format Strings
    0 讨论(0)
  • 2021-01-26 11:54

    24-hour time requires use of HH, not hh. Lowercase h is for 12 hour time.

    See: http://msdn.microsoft.com/en-us/library/8kb3ffffd4%28v=vs.110%29.aspx

    0 讨论(0)
提交回复
热议问题