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

145
Visualizações
Is there an equivalent to moment timezone with a Javascript date?

I have this method below that takes in a Javascript date and then has to use Moment js to do its timezone conversion.

QUESTION - Is there a way to accomplish this without moment, just using a JS Date?

// ex. (someDate, 'America/Los_Angeles', 'MMM DD @ h:mm A z')

transform(dateUtc: Date, timeZone: string, momentFormat: string): string {
  const tempDateUtc = moment(dateUtc).utc(true);
  tempDateUtc.tz(timeZone);
  return tempDateUtc.format(momentFormat);
}

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

0

To apply specific date formatting, rather than a locale based format, then no, not really, but it is possible to get the localized date parts to create a custom format.

As @RobG mentioned, you can use the Intl.DateTimeFormat to create a formatter. You build your options, including your timezone, and then use it's formatToParts(date) method to get the parts you need to construct your output.

Of course, this only works well if your Date is constructed using an epoch or UTC value.

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