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

183
Views
Displaying weekly calendar by clicking a button > in React.tsx

I am trying to create a weekly calendar, so something like Fri, Feb 04 - Thu, Feb 10 which will be dynamic. The first Issue I am trying to solve is to instead of having Fri, Feb 04 - Thu, Feb 10, I want this to be Sun, Jan 30 - Sat, Feb 5 for the entire week, not matter if we are on Friday, it should be displaying that range of dates for the week, and once we reach a new Sunday, then calculate the next range of dates.

const today = new Date().toString();
const endOfWeek = new Date(Date.now() + 6 * 24 * 60 * 60 * 1000).toString();

This is what helps me calculate the end of the week date, I make it into an array by using .split() and then I am able to manipulate the rest of the info but, since it depends on what today's date is and adding 6 days to it, that's why it never stays as Sunday-Saturday.

The second thing I am trying to figure out is to be able to calculate the next week. For example, assuming that I got the Sun-Sat dates to work, how would I go about calculating Sun, Feb 6 - Sat, Feb 12, Sun, Feb 13 - Sat, Feb 19 and so on by just clicking a button that will look like this symbol >, or calculate the previous weeks by clicking <.

I will greatly appreciate if someone can help me figure out how to stay at a static Sun-Sat date instead of Fri-Thu like for example today that is Friday. And I would also appreciate if someone could give me an idea on how to calculate the next week Sun-Sat dates. Thanks in advance!

about 4 years ago · Juan Pablo Isaza
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!