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

182
Vistas
Transport date and time between Javascript and C#

I'm developing an application which deals with date and time in frontend, with Javascript's Date object, and sends this information to the API based on C#... So far I'm thinking about converting the date and time selected by the user in the frontend using the getTime() function, so I can get its milliseconds and then convert to DateTime in C# with the following function

 public static DateTime GetDateFromMilliseconds(double unixTimeStamp)
    { 
        System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
        dtDateTime = dtDateTime.AddMilliseconds(unixTimeStamp).ToLocalTime();
        return dtDateTime;
    }

So, I'd like to know, is there another better way to deal with it?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Newer versions of C# include methods for working with Unix timestamps. For this case, using DateTimeOffset.FromUnixTimeMilliseconds() will save you a few lines of code.

Documentation: https://docs.microsoft.com/en-us/dotnet/api/system.datetimeoffset.fromunixtimemilliseconds?view=net-5.0

about 4 years ago · Juan Pablo Isaza 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