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

109
Visualizações
Vue-moment showing wrong time with timezone set

Not sure what I am doing wrong. I have a laravel 8 application where I am storing my time in UTC with timestamp_no_timezone in postgresql. When I view the time in the database it is showing today's date with 13:45 as the time. When I use vue-moment and display the time with the timezone set to America/New_York it is still showing 1:45 PM and it should be 8:45 AM with the offset. What could I be missing? I have even done a console.log of the timezone from moment and it is showing America/New_York.

This is the expression that I am using:

{{ [ timesheet.start, "YYYY-MM-DD HH:mm:ss" ] | moment("timezone", "America/New_York", "h:mm A") }}

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

0

Convert the stored dateTime to epoch while sending in response.

How you can convert dateTime to epoch there are many ways(send dateTime in epoch in response).

Add in your Model

protected $casts = ['datetime_field' => 'timestamp']

add this method in Laravel class from where you are sending response

    protected function toEpoch($datetime )
    {
        if (gettype($datetime) == 'string') {
            $datetime = new DateTime($datetime);
            return Carbon::instance($datetime)->format('U');
        } else if ($datetime instanceof Carbon) {
            return $datetime->format('U');
        } else if ($datetime != null) {
            return Carbon::instance($datetime)->format('U');
        }
      } 
    }

In vue project

{{new Date(epoch*1000)}}
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