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

165
Visualizações
vue timestamp in particular time zone

I am using a timestamp attribute to display the current time and date on my page.

Is it possible to display it in a particular time zone? I want to display it in ZULU timezone which is static and does not observe daylight saving time.

<script>
import Logger from './Logger'

export default {
  name: 'Navbar',
  components: {
    Logger
  },
  data: {
    timestamp: ""
  },
  created() {
    setInterval(this.getNow, 1000);
  },
  methods: {
    getNow: function() {
      const today = new Date();
      const date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
      const time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds() + " - " +  "ZULU";
      const dateTime = date +' '+ time;
      this.timestamp = dateTime;
    }
  }
}
</script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I believe this is not a Vue question, but a regular JavaScript question because Date() is built into JavaScript. When you first create the Date, it uses the time zone of the host system that created it. Then after the date is created, you can convert it to the ZULU time zone using the builtin toLocaleString function, as shown in this answer: Convert date to another timezone in JavaScript

Here is more information about toLocaleString and how it can be used to convert time zones: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString

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