function convertTZ(date, tzString) {
return new Date((typeof date === "string" ? new Date(date) : date).toLocaleString("en-US", {timeZone: tzString}));
}
Re: Run JS with a different TZ
By: Charles Blackburn to nelgin on Sat Oct 14 2023 10:58:43
function convertTZ(date, tzString) {
return new Date((typeof date === "string" ? new Date(date) : date).toLocaleString("en-US", {timeZone: tzString}));
}
You did actually try this and discovred it doesn't actually work, right?
Re: Run JS with a different TZ
By: Charles Blackburn to nelgin on Sat Oct 14 2023 10:58:43
function convertTZ(date, tzString) {
return new Date((typeof date === "string" ? new Date(date) : date).toLocaleString("en-US", {timeZone: tzString}));
}
You did actually try this and discovred it doesn't actually work, right?
can't say i did, i'm not a jS programmer, but was just throwing an idea out. but there should be a way to do it. In C/Python you can do it
in a similar way. if the string is in UTC you should be able to internally convert it to whatever TZ you want.
Re: Run JS with a different TZ<CUT>
By: Charles Blackburn to nelgin on Sun Oct 15 2023 17:55:26
can't say i did, i'm not a jS programmer, but was just throwing an idea out. but there should be a way to do it. In C/Python you can do it
Unforuntately, there isn't. That's why there's moment-timezone and Luxon. Unfortunately Luxon is too modern to work with the sbbs version of js. moment-timezone is no longer developed or supported but at least it works.
Sysop: | Theclone |
---|---|
Location: | Toronto, ON |
Users: | 4 |
Nodes: | 10 (0 / 10) |
Uptime: | 20:15:09 |
Calls: | 29 |
Calls today: | 3 |
Messages: | 11,306 |