'Moment add time zone offset for start end time
Hello i am trying to add time zone offset for start & end date.
In order to get something like this
start date: Mon May 30 2022 05:00:00 GMT+0000 here offset is (00:00 + 5 hours US central time offset)
end time: Wed Jun 01 2022 04:59:00 GMT+0000 (23:59 + 5 hours offset)
But getting for start date Mon May 29 2022 00:00:00 GMT+0000
Here is my code
export function convertIsoToMomentLocal(iso: string | ParsableDate, timezone = 'CST') {
if (iso && timezone) {
const mo = moment.tz(iso, timezone).startOf('day')
const offset = mo.utcOffset()
const epoch = mo.add(offset, 'm').unix()
console.log(epoch, 'test')
return epoch
}
}
So basically i am trying to determine start date and end date first, and only after that add time zone offset. Any ideas tnx, i have tried everything.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
