Skip to content
On this page

wm-kit / Exports / getMonthDays

Function: getMonthDays

getMonthDays(date?): number

获取某个月有多少天

Parameters

NameTypeDescription
date?string | Date | Dayjs时间,需要查询的年月,可以是字符串也可以是Date类型,不传则查询当前月份

Returns

number

示例:

ts
import { getMonthDays } from 'wm-kit'
getMonthDays(new Date('2023-2-1')) // => 28
getMonthDays('2023-8')  // => 31
getMonthDays('2023-7-1')  // => 31
getMonthDays()  // => 31

Author

高强

Defined in

src/modules/date/index.ts:20

Released under the MIT License.