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

142
Visualizações
How to format a date to always show as UTC

I am trying to format a date such that it always shows as UTC e.g. in the format 'dd/mm/YYYY HH:MM UTC'. So far I have this code:

const options = {
    year: 'numeric',
    month: 'numeric',
    day: 'numeric',
    hour: 'numeric',
    minute: 'numeric',
    timezone: 'UTC',
    timeZoneName: 'short'
};

const formattedTime = new Intl.DateTimeFormat('en-GB', options).format(new Date(unixTimestamp))

However this gives me a time in either GMT or BST, e.g.

24/11/2021, 05:51 GMT
27/10/2021, 05:09 BST

What I would like is for the time to be always shown as UTC so in the case of the above examples:

24/11/2021, 05:51 UTC
27/10/2021, 04:09 UTC

Is there a way to configure DateTimeFormat to do this or should I be using something else? I'd rather not resort to importing a library if at all possible.

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

0

The timezone property of the formatting options object must be in camelCase - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#timezone

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