Home > front end >  Converting a String into Date with specific format
Converting a String into Date with specific format

Time:12-26

I've string in this form "29.07.2022" and I want to convert it to a Date

When I try this :

DateTime.ParseExact("29.07.2022", "dd.mm.yyyy", Globalization.CultureInfo.InvariantCulture)

it's returning the error: String was not recognized as a valid DateTime

What's the best way to achieve this?

CodePudding user response:

DateTime.ParseExact("29.07.2022", "dd.MM.yyyy", Globalization.CultureInfo.InvariantCulture)
                                      ^^

mm is minutes , MM is Month

CodePudding user response:

I slove it The probleme was in the string with an extra whte space at the end "29.07.2022 "

  • Related