-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
小技巧:已知年月,求该月共多少天? #41
Labels
Comments
类似的方式: function getMonthCountDay (year, month) {
return new Date(year, month + 1, 0).getDate()
} |
问题:
|
@ZhangDaZongWei 就是类似于加法进位,减法退位。
|
@troy351 thank you, very much! |
下月的第 0 天,就是上个月的最后一天 |
👻 learning... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
在写日历组件时,曾遇到 已知年月,求该月共多少天? 这样的需求。
最开始思路会是:
代码就不一一列出了,思路代码啥的没啥问题。
这里其实有种更简便的方法,借助
Date
API 处理日期溢出时,会自动往后推延响应时间的规则,直接上代码:验证下:
The text was updated successfully, but these errors were encountered: