跳转至

日期#

参考文档,列出了支持表达式中日期数据转换的内置便利函数。

表达式中的JavaScript

你可以在表达式中使用任何JavaScript。更多信息请参阅表达式

beginningOf(unit?: DurationUnit): Date #

Transforms a Date to the start of the given time period. Returns either a JavaScript Date or Luxon Date, depending on input.

Function parameters#

unitOptionalString enum

A valid string specifying the time unit.

Default: week

One of: second, minute, hour, day, week, month, year


endOfMonth(): Date #

Transforms a Date to the end of the month.

extract(datePart?: DurationUnit): Number #

Extracts the part defined in datePart from a Date. Returns either a JavaScript Date or Luxon Date, depending on input.

Function parameters#

datePartOptionalString enum

A valid string specifying the time unit.

Default: week

One of: second, minute, hour, day, week, month, year


format(fmt: TimeFormat): String #

Formats a Date in the given structure

Function parameters#

fmtRequiredString enum

A valid string specifying the time format. Refer to Luxon | Table of tokens for formats.


isBetween(date1: Date | DateTime, date2: Date | DateTime): Boolean #

Checks if a Date is between two given dates.

Function parameters#

date1RequiredDate or DateTime

The first date in the range.

date2RequiredDate or DateTime

The last date in the range.


isDst(): Boolean #

Checks if a Date is within Daylight Savings Time.

isInLast(n?: Number, unit?: DurationUnit): Boolean #

Checks if a Date is within a given time period.

Function parameters#

nOptionalNumber

The number of units. For example, to check if the date is in the last nine weeks, enter 9.

Default: 0

unitOptionalString enum

A valid string specifying the time unit.

Default: minutes

One of: second, minute, hour, day, week, month, year


isWeekend(): Boolean #

Checks if the Date falls on a Saturday or Sunday.

minus(n: Number, unit?: DurationUnit): Date #

Subtracts a given time period from a Date. Returns either a JavaScript Date or Luxon Date, depending on input.

Function parameters#

nRequiredNumber

The number of units. For example, to subtract nine seconds, enter 9 here.

unitOptionalString enum

A valid string specifying the time unit.

Default: milliseconds

One of: second, minute, hour, day, week, month, year


plus(n: Number, unit?: DurationUnit): Date #

Adds a given time period to a Date. Returns either a JavaScript Date or Luxon Date, depending on input.

Function parameters#

nRequiredNumber

The number of units. For example, to add nine seconds, enter 9 here.

unitOptionalString enum

A valid string specifying the time unit.

Default: milliseconds

One of: second, minute, hour, day, week, month, year


toDateTime(): Date #

Converts a JavaScript date to a Luxon date object.

此页面是否
💬 微信

🚀 与作者交流

关注公众号
n8n实战笔记公众号
n8n实战笔记
📚 教程 💡 案例 🔧 技巧
添加微信
添加作者微信
1对1 专业指导
⚡ 快答 🎯 定制 🚀 支持