0

I want to convert this type of date Thu Oct 31 2019 15:07:23 GMT-0600 (Central Standard Time) to this 2019-10-08T15:07:38 and I'm using mommentjs to convert the date but when I try to implement the next code I only get this 2019-10-23T15:07:23-05:00.

const newDate = moment.parseZone(result).format();

The variable result have this value Thu Oct 31 2019 15:07:23 GMT-0600 (Central Standard Time) and the result is this 2019-10-23T15:07:23-05:00. It doesn't matter if I need to use another library.

ASASCED
  • 61
  • 1
  • 15

1 Answers1

1

try this:

const newDate = moment.parseZone(result).format("YYYY-MM-DDTHH:mm:ss");

docs: https://momentjs.com/docs/#/displaying/format/

Narro
  • 430
  • 5
  • 14
  • Just a question more, how can I set this in a variable type Date?. Moment is an string so I want to know how to make that. – ASASCED Feb 16 '20 at 02:41
  • take a look at this: https://stackoverflow.com/questions/17987647/moment-js-transform-to-date-object – Narro Feb 16 '20 at 02:51