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

116
Views
Get month week number from a date (2022-02-28T10:00:53.393Z) -> 5

How to get week no from a date like moment("2022-02-28T10:00:53.393Z") should return 5. I know about week() but that return week no from start of year like it will give 11 based on the date. I need the week no. from month like week 1 of February or week 5 of February

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

0

Here is the solution for this

const getWeekOfDate = (date) => {
  let startDate = moment(date).startOf('month').date();
  let endDate = moment(date).date();
  let weekCount = 1;
  for (let i = startDate; i <= endDate; i++) {
    if (
      moment(date).date(i).format('dddd') ===
      moment().startOf('week').format('dddd')
    ) {
      weekCount++;
    }
  }
  return weekCount;
};
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!