getMonthOfYear获取第几月
更新: 1970/1/1 字数: 0 字 时长: 0 分钟
说明
getMonthOfYear
是一个计算给定日期是当年第几月的函数。
参数 | 描述 |
---|---|
date | 给定的日期,默认为当前日期,可以是 Date (JavaScript Date 对象)。 |
返回值
- 返回一个
number
,表示给定日期是当年的第几月。
示例
js
import { getMonthOfYear } from 'uviewos';
// 获取当前日期是当年的第几月
const currentMonth = getMonthOfYear();
console.log(currentMonth); // 输出当前日期是当年的第几月
// 获取指定日期是当年的第几月
const specificDate = new Date('2024-09-07');
const monthOfSpecificDate = getMonthOfYear(specificDate);
console.log(monthOfSpecificDate); // 输出指定日期是当年的第几月