Weird Moment-Timezone Behavior | UTC-LT Converstion

40 Views Asked by At

I try to convert UTC Times to Local Times

I have this Script

var moment = require("moment-timezone");

var utcDateStart = moment.utc("2022-03-12").startOf("day");
var utcDateEnd = moment.utc("2022-03-12").endOf("day");


let ltDateStart = utcDateStart.clone().tz("Europe/Berlin").startOf("day").utc();
let ltDateEnd = utcDateEnd.clone().tz("Europe/Berlin").endOf("day").utc();


console.log(ltDateStart, ltDateEnd);

I get this result:

Moment<2022-03-11T23:00:00Z> Moment<2022-03-13T22:59:59Z>

But i expect this:

Moment<2022-03-11T23:00:00Z> Moment<2022-03-12T22:59:59Z>

I dont get it... Is this a bug? How can i achieve this? (without subtracting 1 day)

0

There are 0 best solutions below