网站公告

本次更新:新公告样式

详细教程:vitepress.yiov.top

QQ 频道:******(无效二维码)

Skip to content

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); // 输出指定日期是当年的第几月

Released under the MIT License.

本站访客数 人次 本站总访问量