Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

110
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda