Struggling with Time Zone Conversions

I think its the copy of the timezone library you are using, as I had the same issue with the code you provided.

I then updated the code to pull it directly from the downloads on the moment website (which appears to be exactly the same files BTW and it the started working).

So I recommend deleting the global variables you currently have, and get it to pick them up again.

if (!pm.globals.has("moment_js") || !pm.globals.has("moment_tz")) {
    pm.sendRequest("https://momentjs.com/downloads/moment-timezone-with-data-10-year-range.js", (mtzErr, mtzRes) => {
        pm.sendRequest("https://momentjs.com/downloads/moment.js", (mjsErr, mjsRes) => {
            pm.globals.set("moment_js", mjsRes.text());
            pm.globals.set("moment_tz", mtzRes.text());
        })
    })
}

(new Function(pm.globals.get("moment_js")))();
(new Function(pm.globals.get("moment_tz")))();

console.log(moment.tz("2024-06-26T16:55:00", "America/New_York").format("YYYY-MM-DDTHH:mm:ss ZZ"));
console.log(moment.tz("2024-12-26T16:55:00", "America/New_York").format("YYYY-MM-DDTHH:mm:ss ZZ"));

2 Likes