Skip to content

内置日期和时间方法#

¥Built-in date and time methods

处理日期和时间的方法。

¥Methods for working with date and time.

Python support

你可以在代码节点中使用 Python。它在表达式中不可用。

¥You can use Python in the Code node. It isn't available in expressions.

Method Description Available in Code node?
$now A Luxon object containing the current timestamp. Equivalent to DateTime.now(). ✅
$today A Luxon object containing the current timestamp, rounded down to the day. Equivalent to DateTime.now().set({ hour: 0, minute: 0, second: 0, millisecond: 0 }). ✅
Method Description
_now A Luxon object containing the current timestamp. Equivalent to DateTime.now().
_today A Luxon object containing the current timestamp, rounded down to the day. Equivalent to DateTime.now().set({ hour: 0, minute: 0, second: 0, millisecond: 0 }).

Don't mix native JavaScript and Luxon dates

虽然你可以在 n8n 中使用原生 JavaScript 日期和 Luxon 日期,但它们不能直接互操作。最好 将 JavaScript 日期转换为 Luxon 日期 用户参与,以避免出现问题。

¥While you can use both native JavaScript dates and Luxon dates in n8n, they aren't directly interoperable. It's best to convert JavaScript dates to Luxon to avoid problems.

n8n 提供内置的便捷函数,支持日期表达式中的数据转换。有关更多信息,请参阅 数据转换函数 |日期

¥n8n provides built-in convenience functions to support data transformation in expressions for dates. Refer to Data transformation functions | Dates for more information.