DateTime#
DateTime.day#
Description: 月份中的日期(1-31)
Syntax: DateTime.day
Returns: Number
Type: Luxon
Examples:
1 2 | |
DateTime.diffTo()#
Description: 返回两个 DateTime 之间的差值,以指定的单位表示
Syntax: DateTime.diffTo(otherDateTime, unit)
Returns: Number
Source: Custom n8n functionality
Parameters:
otherDateTime(String|DateTime) - 用于与基础 DateTime 相减的时间点。可以是 ISO 日期字符串或 Luxon DateTime。unit(String|Array) - 可选 - 返回结果的单位或单位数组。可选值: years、months、weeks、days、hours、minutes、seconds、milliseconds。
Examples:
1 2 | |
1 2 3 | |
1 | |
DateTime.diffToNow()#
Description: 返回当前时刻与该 DateTime 之间的差值,以指定的单位表示。如需文本形式的表示,请使用 toRelative()。
Syntax: DateTime.diffToNow(unit)
Returns: Number
Source: Custom n8n functionality
Parameters:
unit(String|Array) - 可选 - 返回结果的单位或单位数组。可选值: years、months、weeks、days、hours、minutes、seconds、milliseconds。
Examples:
1 2 | |
1 2 | |
1 | |
DateTime.endOf()#
Description: 将 DateTime 向上取整到某个单位的末尾,例如月末
Syntax: DateTime.endOf(unit, opts)
Returns: DateTime
Type: Luxon
Parameters:
unit(String) - 要取整到末尾的单位。可以是year、quarter、month、week、day、hour、minute、second或millisecond。opts(Object) - 可选 - 包含影响输出选项的对象。可用属性:useLocaleWeeks(boolean):是否在计算一周的开始时使用区域设置。默认为 false。
Examples:
1 2 | |
DateTime.equals()#
Description: 如果两个 DateTime 表示完全相同的时刻且处于相同的时区,则返回 true。如需不太严格的比较,请使用 hasSame()。
Syntax: DateTime.equals(other)
Returns: Boolean
Type: Luxon
Parameters:
other(DateTime) - 要比较的另一个 DateTime
Examples:
1 2 3 | |
DateTime.extract()#
Description: 提取日期或时间的某个部分(如月份),以数字形式返回。如需提取文本名称,请参见 format()。
Syntax: DateTime.extract(unit?)
Returns: Number
Source: Custom n8n functionality
Parameters:
unit(String) - 可选 - 要返回的日期或时间部分。可选值:year、month、week、day、hour、minute、second
Examples:
1 2 | |
1 2 | |
DateTime.format()#
Description: 使用指定的格式将 DateTime 转换为字符串。格式化指南。对于常见格式,toLocaleString() 可能更简便。
Syntax: DateTime.format(fmt)
Returns: String
Source: Custom n8n functionality
Parameters:
fmt(String) - 返回字符串的格式
Examples:
1 2 | |
1 2 3 4 | |
DateTime.hasSame()#
Description: 如果两个 DateTime 在指定的单位精度下相同,则返回 true。时区会被忽略(仅比较本地时间),如有需要请先使用 toUTC()。
Syntax: DateTime.hasSame(otherDateTime, unit)
Returns: Boolean
Type: Luxon
Parameters:
otherDateTime(DateTime) - 要比较的另一个 DateTimeunit(String) - 要检查的时间单位精度。可选值:year、quarter、month、week、day、hour、minute、second或millisecond。
Examples:
1 2 3 | |
1 2 3 | |
DateTime.hour#
Description: 一天中的小时(0-23)
Syntax: DateTime.hour
Returns: Number
Type: Luxon
Examples:
1 2 | |
DateTime.isBetween()#
Description: 如果该 DateTime 位于指定的两个时间点之间,则返回 true
Syntax: DateTime.isBetween(date1, date2)
Returns: Boolean
Source: Custom n8n functionality
Parameters:
date1(String|DateTime) - 基础 DateTime 必须晚于的时间点。可以是 ISO 日期字符串或 Luxon DateTime。date2(String|DateTime) - 基础 DateTime 必须早于的时间点。可以是 ISO 日期字符串或 Luxon DateTime。
Examples:
1 2 | |
1 2 | |
DateTime.isInDST#
Description: 该 DateTime 是否处于夏令时
Syntax: DateTime.isInDST
Returns: Boolean
Type: Luxon
DateTime.locale#
Description: DateTime 的区域设置,如 'en-GB'。区域设置用于格式化 DateTime。
Syntax: DateTime.locale
Returns: String
Type: Luxon
Examples:
1 | |
DateTime.millisecond#
Description: 秒中的毫秒(0-999)
Syntax: DateTime.millisecond
Returns: Number
Type: Luxon
Examples:
1 2 | |
DateTime.minus()#
Description: 从 DateTime 中减去指定的时间段
Syntax: DateTime.minus(n, unit?)
Returns: DateTime
Source: Custom n8n functionality
Parameters:
n(Number|Object) - 要减去的单位数量。也可以使用 Luxon Duration 对象一次减去多个单位。unit(String) - 可选 - 数字的单位。可选值:years、months、weeks、days、hours、minutes、seconds、milliseconds
Examples:
1 2 | |
1 2 | |
DateTime.minute#
Description: 小时中的分钟(0-59)
Syntax: DateTime.minute
Returns: Number
Type: Luxon
Examples:
1 2 | |
DateTime.month#
Description: 月份(1-12)
Syntax: DateTime.month
Returns: Number
Type: Luxon
Examples:
1 2 | |
DateTime.monthLong#
Description: 月份的完整文本名称,例如 'October'。如果未指定区域设置,则默认使用系统区域设置。
Syntax: DateTime.monthLong
Returns: String
Type: Luxon
Examples:
1 2 | |
1 2 | |
DateTime.monthShort#
Description: 月份的缩写文本名称,例如 'Oct'。如果未指定区域设置,则默认使用系统区域设置。
Syntax: DateTime.monthShort
Returns: String
Type: Luxon
Examples:
1 2 | |
1 2 | |
DateTime.plus()#
Description: 向 DateTime 添加指定的时间段
Syntax: DateTime.plus(n, unit?)
Returns: DateTime
Source: Custom n8n functionality
Parameters:
n(Number|Object) - 要添加的单位数量。也可以使用 Luxon Duration 对象一次添加多个单位。unit(String) - 可选 - 数字的单位。可选值:years、months、weeks、days、hours、minutes、seconds、milliseconds
Examples:
1 2 | |
1 2 | |
DateTime.quarter#
Description: 一年中的季度(1-4)
Syntax: DateTime.quarter
Returns: Number
Type: Luxon
Examples:
1 2 | |
DateTime.second#
Description: 分钟中的秒(0-59)
Syntax: DateTime.second
Returns: Number
Type: Luxon
Examples:
1 2 | |
DateTime.set()#
Description: 为 DateTime 的指定单位赋予新值。如需对 DateTime 取整,另请参阅 startOf() 和 endOf()。
Syntax: DateTime.set(values)
Returns: DateTime
Type: Luxon
Parameters:
values(Object) - 包含要设置的单位和对应值的对象。可用键名:year、month、day、hour、minute、second和millsecond。
Examples:
1 2 | |
DateTime.setLocale()#
Description: 设置区域设置,用于确定 DateTime 的语言和格式。在生成 DateTime 的文本表示时很有用,例如使用 format() 或 toLocaleString()。
Syntax: DateTime.setLocale(locale)
Returns: DateTime
Type: Luxon
Parameters:
locale(String) - 要指定的区域设置,例如 'en-GB'(英式英语)或 'pt-BR'(巴西葡萄牙语)。列表(非官方)
Examples:
1 | |
1 | |
DateTime.setZone()#
Description: 将 DateTime 转换为指定的时区。除非在选项中另行指定,DateTime 仍然表示相同的时刻。另请参阅 toLocal() 和 toUTC()。
Syntax: DateTime.setZone(zone, opts)
Returns: DateTime
Type: Luxon
Parameters:
zone(String) - 可选 - 时区标识符,格式为 'America/New_York'、'UTC+3',或字符串 'local' 或 'utc'opts(Object) - 可选 - 影响输出的选项。可用属性:keepCalendarTime(boolean):是否保持时间不变而仅更改偏移量。默认为 false。
Examples:
1 2 | |
1 2 | |
DateTime.startOf()#
Description: 将 DateTime 向下取整到某个单位的开始,例如月初
Syntax: DateTime.startOf(unit, opts)
Returns: DateTime
Type: Luxon
Parameters:
unit(String) - 要取整到开始的单位。可选值:year、quarter、month、week、day、hour、minute、second或millisecond。opts(Object) - 可选 - 包含影响输出选项的对象。可用属性:useLocaleWeeks(boolean):是否在计算一周的开始时使用区域设置。默认为 false。
Examples:
1 2 | |
DateTime.toISO()#
Description: 返回 DateTime 的 ISO 8601 标准字符串表示
Syntax: DateTime.toISO(opts)
Returns: String
Type: Luxon
Parameters:
opts(Object) - 可选 - 配置选项。详见 Luxon 文档。
Examples:
1 | |
DateTime.toLocal()#
Description: 将 DateTime 转换为工作流的本地时区。除非在参数中另行指定,DateTime 仍然表示相同的时刻。工作流的时区可以在工作流设置中更改。
Syntax: DateTime.toLocal()
Returns: DateTime
Type: Luxon
Examples:
1 2 | |
DateTime.toLocaleString()#
Description: 返回 DateTime 的本地化字符串表示,即使用其区域设置对应的语言和格式。如果未指定区域设置,则默认使用系统区域设置。
Syntax: DateTime.toLocaleString(formatOpts)
Returns: String
Type: Luxon
Parameters:
formatOpts(Object) - 可选 - 渲染的配置选项。完整列表请参见 Intl.DateTimeFormat。默认渲染短日期格式。
Examples:
1 2 3 | |
1 | |
1 2 3 4 5 | |
1 2 3 4 5 | |
1 2 3 4 5 | |
1 2 3 | |
DateTime.toMillis()#
Description: 返回以毫秒为单位的 Unix 时间戳(自 1970 年 1 月 1 日以来经过的毫秒数)
Syntax: DateTime.toMillis()
Returns: Number
Type: Luxon
Examples:
1 | |
DateTime.toRelative()#
Description: 返回相对于当前时间的文本表示,例如 'in two days'。默认向下取整。
Syntax: DateTime.toRelative(options)
Returns: String
Type: Luxon
Parameters:
options(Object) - 可选 - 影响输出的选项。可用属性:unit= 默认使用的单位(years、months、days等)。locale= 使用的语言和格式(例如de、fr)
Examples:
1 | |
1 | |
1 | |
DateTime.toSeconds()#
Description: 返回以秒为单位的 Unix 时间戳(自 1970 年 1 月 1 日以来经过的秒数)
Syntax: DateTime.toSeconds()
Returns: Number
Type: Luxon
Examples:
1 | |
DateTime.toString()#
Description: 返回 DateTime 的字符串表示。类似于 toISO()。如需更多格式化选项,请参见 format() 或 toLocaleString()。
Syntax: DateTime.toString()
Returns: string
Type: Luxon
Examples:
1 | |
DateTime.toUTC()#
Description: 将 DateTime 转换为 UTC 时区。除非在参数中另行指定,DateTime 仍然表示相同的时刻。使用 setZone() 可转换到其他时区。
Syntax: DateTime.toUTC(offset, opts)
Returns: DateTime
Type: Luxon
Parameters:
offset(Number) - 可选 - 相对于 UTC 的偏移量(以分钟为单位)opts(Object) - 可选 - 包含影响输出选项的对象。可用属性:keepCalendarTime(boolean):是否保持时间不变而仅更改偏移量。默认为 false。
Examples:
1 2 | |
DateTime.weekday#
Description: 一周中的第几天。1 表示星期一,7 表示星期日。
Syntax: DateTime.weekday
Returns: Number
Type: Luxon
Examples:
1 2 | |
DateTime.weekdayLong#
Description: 星期几的完整文本名称,例如 'Wednesday'。如果未指定区域设置,则默认使用系统区域设置。
Syntax: DateTime.weekdayLong
Returns: String
Type: Luxon
Examples:
1 2 | |
1 2 | |
DateTime.weekdayShort#
Description: 星期几的缩写文本名称,例如 'Wed'。如果未指定区域设置,则默认使用系统区域设置。
Syntax: DateTime.weekdayShort
Returns: String
Type: Luxon
Examples:
1 2 | |
1 2 | |
DateTime.weekNumber#
Description: 一年中的第几周(1-52 左右)
Syntax: DateTime.weekNumber
Returns: Number
Type: Luxon
Examples:
1 2 | |
DateTime.year#
Description: 年份
Syntax: DateTime.year
Returns: Number
Type: Luxon
Examples:
1 2 | |
DateTime.zone#
Description: 与该 DateTime 关联的时区
Syntax: DateTime.zone
Returns: Object
Type: Luxon
Examples:
1 | |