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

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

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 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