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

186
Views
Moment.js date/time base on diff timezone offset

I'm not sure how to spit out the right date/time using moment.js base on diff timezone offset

I've tried USA : MA & TX

console.log(moment().utcOffset('-5').format('ddd MM/DD/y H:mm:ss')); //MA
console.log(moment().utcOffset('-6').format('ddd MM/DD/y H:mm:ss')); //TX

I kept getting

Fri 09/17/2021 18:28:21 //MA
Fri 09/17/2021 18:28:21 //TX

I supposed to get

Fri 09/17/2021 18:28:21 //MA
Fri 09/17/2021 17:28:21 //TX

Any hints for me ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try this

console.log(moment.utc().format('ddd MM/DD/y H:mm:ss'), 'UTC');
console.log(moment.utc().add(-5, 'hours').format('ddd MM/DD/y H:mm:ss'), 'MA');
console.log(moment.utc().add(-6, 'hours').format('ddd MM/DD/y H:mm:ss'), 'TX');
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.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!