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

235
Views
How to format a date string in ISO 8601 format(2022-04-10T15:58:25.549+01:00) in Javascript under POSTMAN?

const d = new Date(); console.log(d); // output is 2022-04-11T10:29:46.644Z

The above code showing time for GMT, but i want to print time for Ex: GMT+1 in format like "2022-04-11T10:29:46.644+01:00.

I am using postman so can not use moment-timezone My current code:

var date = new Date().toISOString(true); pm.environment.set("todaydate", date);

"errorSource": "Invalid date offset for value 2022-10-11T13:24:37.197z of offset is +01:00.

i.e value should be 2022-10-11T13:24:37+01:00

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

you can timezone info from new Date().getTimezoneOffset()

const timeoffset = new Date().getTimezoneOffset()
console.log(timeoffset) 
//output : -330 which is  GMT -330minutes 

//you can convert to hours using
const inHours = timeoffset>0 ?
'-'+Math.floor(timeoffset/60).toString().padStart(2,'0')+':'+(timeoffset%60).toString().padEnd(2,'0')
:
Math.floor((-1*timeoffset)/60).toString().padStart(2,'0')+':'+((-1*timeoffset)%60).toString().padEnd(2,'0')
console.log(inHours);

about 4 years ago · Santiago Trujillo Report

0

If moment.js is not an option, can you can use dayjs - https://day.js.org/

about 4 years ago · Santiago Trujillo 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!