Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

292
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda