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

163
Visualizações
The DateTime.MinValue is converted into 0001-01-01 08:05:43 in Javascript

The server side is in C# and it returns object array list as json format. There is one field in the object model, it is DateTime type, and its value is DateTime.MinValue.

While in the page side, it receives /Date(-62135596800000)/ in string. I guess this is because of the object is serialized. And in javascirpt, I try to convert it back to Date type.

var timeSpan = element.DateModify.replace('Date','').replace('(','').replace(')','').replace(/\//g,'');
console.log(timeSpan);
var d = new Date(parseInt(timeSpan));
console.log(d);

When converted to Date in javascript, its value is 0001-01-01 08:05:43, not 0001-01-01 00:00:00. Why is it?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

DateTime.MinValue is 0001-01-01 00:00:00 UTC. And that is indeed 0001-01-01 08:05:43 in your local time zone (whatever that may be, probably Asia/Shanghai or somewhere near that). When you console.log a Date, it displays the date in your local time zone. The Date value is correct. It's just displayed in a different format.

The extra 5 minutes and 43 seconds is because at the year AD 1, time zones have not been standardised, and the local mean time offset from UTC at your location is +08:05:43.

Two simple ways to make it display the UTC time of 00:00:00 is to call toISOString or toUTCString:

console.log(new Date(-62135596800000).toISOString());
console.log(new Date(-62135596800000).toUTCString());

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