Created
May 20, 2022 03:16
-
-
Save CongAn/b7d5ee20e1ee7ca689687e56b951b390 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const date = moment() | |
const firstDayOfYear = moment(date.format('YYYY-01-01')) | |
// 获得第多少周(跨年周算第一周) | |
const weeks = ( | |
// 获得第多少天 | |
date.diff(firstDayOfYear, 'days') - | |
// 减去第一周天数 | |
(7 - firstDayOfYear.weekday()) - | |
// 减去该时间当前周的天数 | |
date.weekday() | |
) / 7 + 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment