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

197
Views
How to get the first day of week with year?
// result is: 2014/12/29
moment('2016/01/01').isoWeek(1).startOf('isoWeek').format("YYYY/MM/DD")

// result is: 2016/01/04
moment().year(2016).isoWeek(1).startOf('isoWeek').format("YYYY/MM/DD")

The second is right, but I don't know why the first go wrong?

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

0

ISO week does not always start on January 1st. It might start few days before of after. https://en.wikipedia.org/wiki/ISO_week_date#First_week

The first ISO week of 2016 starts in 2016/01/04, so 2016/01/01 is in 2015 by the ISO weeks count, and moment('2016/01/01').isoWeek(1) gives the first week of 2015, that actually start few days before 2015, in 2014/12/29.

For the question in the title - the second statement with .year(2016) indeed works so you may use it.

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!