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

177
Views
how to convert date object to string using javascript

I have a date object as follows let dateObj = Sat May 01 2021 20:21:00 GMT-0700 (Pacific Daylight Time)

I want to convert above value in this string format. let stringVal = 2021-05-01T20:21:00.000+0000

can someone let me know how to achieve this. i Have tried toUTCString(), to DateString(), toISOString() and all other methods but i was not able to achieve the result in the format above.

Any guidance is appreciated. is it even possible ?

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

0

Not sure if you wanted it converted to UTC, but based on your example it looks like not.

Maybe something like this? Just replace "new Date()" with your date object.

const date = new Date(new Date() - 1000 * 60 * 60 * 7); // subtract 7 hours since .toISOString() is going to add 7 hours
console.log(date.toISOString().replace('Z','+0000'));

* I should add this assumes the client's timezone is Pacific Daylight Time, or a least something with the same offset

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!