Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

DateTime.TryParseExtract with 'hh' or 'h' as format string.

$
0
0

Hi,

As per MSDN documentation for custom datetime format strings:

The "h" custom format specifier represents the hour as a number from1 through 12

The "hh" custom format specifier (plus any number of additional "h" specifiers) represents the hour as a number from 01 through 12.

However, when i try to parse '00' to DateTime using TryParseExtract(), it returns true. I was expecting the return value as false.

Code snippet:

DateTime dateTime;

var bRet = DateTime.TryParseExact("00", "hh", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime);


Thanks

Suneel


Viewing all articles
Browse latest Browse all 8156


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>