Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

290
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda