I know that a user is available on the next Sunday in timezone America/New_York at 13:00. How can I get the date (in format January 12, 2022 9:00 am) of the next Sunday in that timezone and then convert that to a user's current timezone (i.e. America/Los_Angeles) using moment.timezone library?
I know how to do this using utc, but not with timezones involved.
function nextWeekdayDate(date, day_in_week) {
var ret = new Date(date||new Date());
ret.setDate(ret.getDate() + (day_in_week - 1 - ret.getDay() + 7) % 7 + 1);
return ret;
}
var date = new Date();
console.log(nextWeekdayDate(date, 5));