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

157
Vistas
Using moment to define time in an UTC-based cloud server?

My application heavily relines on time being on pacific time If I deploy my application on Google App Engine (US-WEST region), the time that is calculated by the cloud app engine is different than my local machine.

I've tried using Moment-Timezone to make it force the cloud server machine to use los angeles time format however its still giving me a different time than my local machine.

Is there a way to use moment so that the time values are consistent no matter where its deployed? Or did I implement the moment-time zone incorrectly?

const test = moment(new Date(filteredTimeLeft))
const endTime = test.tz('America/Los_Angeles').unix();
console.log('endTime', endTime)
const convertSec = Number(coin.seconds);
console.log('convertSec', convertSec)
const newDate = moment(new Date())
const calcTime = endTime - convertSec - newDate.tz('America/Los_Angeles').unix();
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Not sure how you came with usin the plain JS new Date along with moment, nor the use of unix().

And I don't know what coin.seconds can be...

Anyway, here an example showing

  • the plain JS date
  • the UTC time
  • your local time
  • the Los Angeles time
  • the New York time

let js_date = new Date();
console.log("Plain JS date", js_date);

let moment_UTC = moment().utc();
console.log("UTC time", moment_UTC.format("hh:mm:ss"));

let moment_local = moment();
console.log("Your local time", moment_local.format("hh:mm:ss"));

let moment_Los_Angeles = moment().tz('America/Los_Angeles');
console.log("Los Angeles", moment_Los_Angeles.format("hh:mm:ss"));

let moment_New_York = moment().tz('America/New_York');
console.log("New York", moment_New_York.format("hh:mm:ss"));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src="https://momentjs.com/downloads/moment-timezone-with-data.js"></script>

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