Skip to content

内置日期和时间方法(Built-in date and time methods)#

处理日期和时间的方法。

🌐 Methods for working with date and time.

Python support

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 }).

不要混合使用原生 JavaScript 日期和 Luxon 日期

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

n8n 提供了内置的便捷函数,以支持在表达式中对日期进行数据转换。更多信息请参阅 数据转换函数 | 日期

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