I am working in a react-native project and using moment library. I am getting issue while converting time (in GMT 5:30 IST) to AM/PM. It adds 5:30 hours in local current time.
eg. From database time 3:00PM. After passing from new Date() =>
time converts to Wed Jun 23 2021 15:00:00 GMT+0530
(India Standard Time) and in the field where i need. when i am converting this GMT time to Am/PM again when i need. It shows 8:30PM instead of 3:00PM.
Here is the code:
var scheduledDeparture = Wed Jun 23 2021 15:00:00 GMT+0530 (India Standard Time)
scheduledDeparture_Time: new Date(ScheduledDeparture),
let finalTime = moment.utc(leavedata.scheduledDeparture_Time).format('hh:mm a').replace(/GMT.*/g,"")
console.log("finalTime ",finalTime). // 08:30PM
Why GMT time is adding 5:30 in current time and how to overcome from it?