Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
Get the next Monday in a user's timezone

This post was very useful Getting the date of next Monday when it comes to figuring out how to get the next Monday in UTC time. I have the following problem.

I want to get the next Monday in user A's timezone and then convert that to user's B timezone. How can I do that?

So if user A's timezone is America/New_York and the date is January 2, 2022, I want to get the next Monday in that timezone. Then convert that date to user B's timezone. How can I do that using javascript or moment js?

The goal is to get the next availability of a user so that another user in a different timezone can set up an appointment with him.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If I'm getting your question right you want to get the date at a different time zone then get the next Monday then convert it to a time zone you want. If so this should work:

Note: this uses Moment js and moment time zone libraries. The "moment time zone with data" library is a little bulky so if you are concerned about performance then CDN might not be the way to go try node js.

function getNextMonday() {
  const now = new Date()
  const today = new Date(now)
  today.setMilliseconds(0)
  today.setSeconds(0)
  today.setMinutes(0)
  today.setHours(0)

  const nextMonday = new Date(today)

  do {
    nextMonday.setDate(nextMonday.getDate() + 1) // Adding 1 day
  } while (nextMonday.getDay() !== 1)

  return nextMonday
}

var cur_date = moment(getNextMonday());
//this gives the corrsponding date on specific time zone of next monday
console.log(cur_date.tz('America/Los_Angeles').format())
<script src="https://momentjs.com/downloads/moment.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.31/moment-timezone-with-data.js"></script>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!