[Fixed] How to create non changeable date using moment?

Issue

Why this function changing time to indian time. I want to set it as same as written in code. So that I can compare it with current indian time. How can I do that?

const moment = require('moment');
console.log(moment.parseZone('2016-04-12T03:52:57+05:30'))

Solution

You will have to parse the date as UTC.

https://momentjs.com/docs/#/parsing/utc/

console.log(moment.utc('2016-04-12T03:52:57+05:30'))

Otherwise, moment will read it as local time.

Leave a Reply

(*) Required, Your email will not be published