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

197
Vistas
Datetime parse "2021-04-20T00:09:14.7724640+02:00"

Best way to parse time = "2021-04-20T00:09:14.7724640+02:00" to valid time. I need seconds as well however once

var h = DateTime.ParseExact(time.Substring(14,5), "hh:mm", CultureInfo.InvariantCulture);

this returns only hour and minute but I need seconds too, however there is 09:14.7724640+02:00 and if I tried hh:mm:ss the "." throws an "Invalid DateTimet "exception

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

string time = "2021-04-20T00:09:14.7724640+02:00";
DateTime dateTime = DateTime.Parse(time);

With this you have the whole string in the DateTime object and can do whatever you want with it (e.g. cut out hours, minutes and seconds).

over 4 years ago · Santiago Trujillo Denunciar

0

You are looking for a timespan, datetime also contains a date part.

If you use the following code you will get a DateTime an a TimeSpan

var timeString = "2021-04-20T00:09:14.7724640+02:00";
var dateTime = DateTime.Parse(timeString);
var time = dateTime.TimeOfDay;
Console.WriteLine(time);
over 4 years ago · Santiago Trujillo Denunciar

0

you can use ToString("dd MMMM, yyyy") and give it the format that you want

public static string GetDate(DateTime date)
        {
            return date.ToString("dd MMMM, yyyy");
        }
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