在 Neo4j 中将日期时间转换为时间戳

Convert datetime to timestamp in Neo4j

如何将Neo4j加载的数据中的日期时间转换为时间戳? 日期时间格式示例:2020-04-07T12:39:38.027Z 请协助。

Neo4 的时间瞬间(如 datetime)有一个特殊变量,epochMillis,它提供等效的纪元时间。

例如:

RETURN datetime('2020-04-07T12:39:38.027Z').epochMillis

returns

1586263178027

您可以先使用 epochMillis and passing that to the apoc.date.toISO8601 函数将日期时间转换为时间戳,从而将日期时间转换为字符串。

WITH datetime() as dt
RETURN apoc.date.toISO8601(dt.epochMillis, "ms") AS iso8601

returns

"2022-04-30T18:56:53.145Z"