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

159
Visualizações
How to use FormatJS to format date and time in the same way as in Intl.DateTimeFormat

In my react app I used the javascript Intl.DateTimeFormat() to format date and time in the way I need. Link to this Intl.DateTimeFormat()

I would like to move the same formatted date and time to the FormatJS Intl library.

I tried to understand the documentation but I have no idea how to achieve the same as was done using Intl.DateTimeFormat().

This is an example of one method

const ZoneDateTime = ({ dateTime, timeZone }) => {
  let locale;

  if (timeZone.includes('Europe')) locale = 'en-SE';
  if (timeZone.includes('America')) locale = 'en-US';
  if (timeZone.includes('Etc')) locale = 'en-EN';
  if (timeZone.includes('Europe/London')) locale = 'en-GB';

  const formatter = Intl.DateTimeFormat(locale, {
    timeZone,
    year: 'numeric',
    month: 'short',
    day: 'numeric',
    hour: 'numeric',
    minute: 'numeric',
  });

  return formatter.format(dateTime) + ` (${timeZone})`;
};

Practically the result of this depending of what timezone we have is an example

19 Aug 2021, 02:00 (Europe/Stockholm)

So my question is how to reproduce the same using the FormatJs library and IntlShape to show the same date and time

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