date.month() 函数
date.month()
返回指定时间的月份。结果范围为 [1 - 12]
。
返回值 | 月份 |
---|---|
1 | 一月 |
2 | 二月 |
3 | 三月 |
4 | 四月 |
5 | 五月 |
6 | 六月 |
7 | 七月 |
8 | 八月 |
9 | 九月 |
10 | 十月 |
11 | 十一月 |
12 | 十二月 |
函数类型签名
(t: A, ?location: {zone: string, offset: duration}) => int where A: Timeable
有关更多信息,请参阅 函数类型签名。
参数
t
(必需)要操作的时间。
使用绝对时间、相对持续时间或整数。持续时间相对于 now()
。
location
用于确定时区的 Location。默认为 location
选项。
示例
返回时间值的月份
import "date"
date.month(t: 2020-02-11T12:21:03.29353494Z)// Returns 2
返回相对持续时间的月份
import "date"
option now = () => 2020-02-11T12:21:03.29353494Z
date.month(t: -3mo)// Returns 8
返回当前数字月份
import "date"
date.month(t: now())
此页是否对您有帮助?
感谢您的反馈!