日期
一份参考文档,列出了支持日期
表达式中数据转换的内置便利函数。beginOf(单位?:DurationUnit):日期
Transforms a Date to the start of the given time period. Returns either a JavaScript Date or Luxon Date, depending on input.
函数参数
unitOptionalString enum
指定时间单位的有效字符串。
endOfMonth():日期
Transforms a Date to the end of the month.
提取(datePart?:DurationUnit):数字
Extracts the part defined in datePart from a Date. Returns either a JavaScript Date or Luxon Date, depending on input.
函数参数
datePartOptionalString enum
指定时间单位的有效字符串。
格式(fmt:时间格式):字符串
Formats a Date in the given structure
函数参数
isBetween(date1:日期 | 日期时间,date2:日期 | 日期时间):布尔值
Checks if a Date is between two given dates.
函数参数
date1RequiredDate or DateTime
范围内的第一个日期。
date2RequiredDate or DateTime
范围内的最后一个日期。
isDst(): 布尔值
Checks if a Date is within Daylight Savings Time.
isInLast(n?:数字,单位?:持续时间单位):布尔值
Checks if a Date is within a given time period.
函数参数
nOptionalNumber
单位数。例如,要检查日期是否在过去九周内,请输入 9。
unitOptionalString enum
指定时间单位的有效字符串。
isWeekend(): 布尔值
Checks if the Date falls on a Saturday or Sunday.
减(n:数字,单位?:持续时间单位):日期
Subtracts a given time period from a Date. Returns either a JavaScript Date or Luxon Date, depending on input.
函数参数
nRequiredNumber
单位数。例如,要减去 9 秒,请在此处输入 9。
unitOptionalString enum
指定时间单位的有效字符串。
加法(n:数字,单位?:持续时间单位):日期
Adds a given time period to a Date. Returns either a JavaScript Date or Luxon Date, depending on input.
函数参数
nRequiredNumber
单位数。例如,要添加 9 秒,请在此处输入 9。
unitOptionalString enum
指定时间单位的有效字符串。
toDateTime():日期
Converts a JavaScript date to a Luxon date object.