DateTime ParseExact转换每月增加1

Tan*_*moy 1 c# datetime

尝试使用ParseExact将字符串转换为日期时间,但结果日期时间似乎是将月份增加1.我错过了什么

DateTime.ParseExact("7/22/2015 8:08:01 PM", "m/d/yyyy h:M:s tt", CultureInfo.InvariantCulture)
Run Code Online (Sandbox Code Playgroud)

结果: 22-08-2015 20:07:01

LIn*_*Teh 5

你混了m,并M为分月.所以看起来月份增加1只是巧合.

正确的代码是:

DateTime.ParseExact("7/22/2015 8:08:01 PM", "M/d/yyyy h:m:s tt", CultureInfo.InvariantCulture)
Run Code Online (Sandbox Code Playgroud)