Get week of year in JavaScript like in PHP

后端 未结 19 1624
南方客
南方客 2020-11-22 02:38

How do I get the current weeknumber of the year, like PHP\'s date(\'W\')?

It should be the ISO-8601 week number of year, weeks starting

19条回答
  •  野的像风
    2020-11-22 03:10

    Another library-based option: use d3-time-format:

    const formatter = d3.timeFormat('%U');
    const weekNum = formatter(new Date());
    

提交回复
热议问题