Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!