-1

I've angular application with moment@2.24.0. I do this simple actions:

 let test = moment('2019112200:00','YYYYMMDDmm:ss');
 console.log(test .toJSON());

the result is

2019-11-21T23:00:00.000Z

i think it doesn't consider timezone. With

moment.locale('it')

the result is the same.

The workaround can be moment.format() but i would use the right solution.

Here fiddle to replicate https://jsfiddle.net/crakdelpol/r6yu2abL/1/

Pippi
  • 313
  • 1
  • 4
  • 18
  • 1
    From [`toJSON()`](https://momentjs.com/docs/#/displaying/as-json/) doc: _When serializing an object to JSON, if there is a `Moment` object, it will be represented as an ISO8601 string, adjusted to UTC._ – VincenzoC Nov 22 '19 at 11:19

1 Answers1

0

A valid alternative is

test.ISOString(true)

Result is: 2019-11-22T00:00:00.000+01:00

Pippi
  • 313
  • 1
  • 4
  • 18