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

237
Views
How to convert one time format to another in javascript using moment.tz?

I have tried various methods but I'm unable to convert date like 1640638800 to 2022-11-27 16:00:00 America/New_York timezone format in javascript using moment.tz.

My current code was like

import * as moment from 'moment';
var date= new Date(0);
date.setUTCSeconds(1640638800);
moment.tz(date.getFullYear()+"-"+date.getMonth()+"-"+date.getDay() + " 10:00:00", "America/New_York");
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

import moment from 'moment-timezone'

// Unix Timestamp (milliseconds)
const ts = 1640638800 * 1000 

// Parse as timezoned moment
const m = moment.tz(ts, "America/New_York")

// Format moment to string
const formatted = m.format('YYYY-MM-DD HH:mm:ss')

console.log(formatted) // '2021-12-27 16:00:00'
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!