Parse Simple DateTime

后端 未结 3 910
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-17 19:40
DateTime dt = DateTime.ParseExact(\"1122010\", \"Mddyyyy\", System.Globalization.CultureInfo.CurrentCulture);

Throwing this exception: String was

3条回答
  •  清酒与你
    2021-01-17 20:01

    The single "M" format string is unacceptable because not all months can be uniquely represented with a single digit or character. As previously suggested, you will have to use "MMddyyyy" and pad the left string when necessary.

提交回复
热议问题