Get week of year in JavaScript like in PHP

后端 未结 19 1314
南方客
南方客 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 02:59

    With Luxon (https://github.com/moment/luxon) :

    import { DateTime } from 'luxon';
    const week: number = DateTime.fromJSDate(new Date()).weekNumber;
    

提交回复
热议问题