Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
Parsing a string to datetime in .netcore from format dd.MM.yyyy hh:mm:ss

I found similar questions, but none is covered this case.

Im trying to do follows:

string dateTime = "28.11.2020 16:08:43"

var date = DateTime.ParseExact(dateTime, "dd.MM.yyyy hh:mm:ss", CultureInfo.InvariantCulture)

but Im getting exception:

System.FormatException: String '28.11.2020 16:08:43' was not recognized as a valid DateTime.
   at System.DateTime.ParseExact(String s, String format, IFormatProvider provider)
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You're using hh in your format string, which means "hour of halfday, in the range 1-12". You want HH, which means "hour of day, in the range 0-23". The actual value (16) isn't in the range 1-12, hence the error.

Any time you run into date/time formatting or parsing issues, it's worth checking your date/time format very, very carefully against the documentation.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!