-1

I would like to convert a Javascript Date (as in const currentDate = new Date();) to the format below:

YYYY-MM-DDTHH:MM:SS+00:00 (I know the timezone will depend on the timezone I am).

But I need the timezone in this format: +HH:00 or -HH:00. I guess the minutes for a timezone will always be zero (but maybe there are some half timezones somewhere).

Anyway, the snippet below for the current date gives me this result:

2019-11-20T18:02:57.568Z

Is there an automated way to do that conversion? Or maybe an npm package.

const currentDate = new Date();
console.log(currentDate.toISOString());
cbdeveloper
  • 27,898
  • 37
  • 155
  • 336

1 Answers1

1

There is a NPM package which may do what you want to do in terms of converting these date-times. the link is attached below to the packages NPM page.

https://www.npmjs.com/package/date-and-time

I believe you can use the date.compile() function for your specified results.

Striker
  • 626
  • 1
  • 7
  • 24