apoc.date.currentTimestamp
Syntax |
|
||
Description |
Returns the current Unix epoch timestamp in milliseconds. |
||
Returns |
|
Getting the current time using Cypher
Getting the current time using Cypher can be done using the Temporal functions - instant types.
These functions retrieve real time (time of function call), time tied to the statement, or time tied to the current transaction.
Cypher syntax for getting the current datetime
RETURN datetime.realtime()
Usage Examples
The following examples return the current timestamp in ms using both APOC and Cypher:
apoc.date.currentTimestamp
WITH apoc.date.currentTimestamp() AS outputInMs
RETURN outputinMs, datetime({epochMillis: output}) AS datetime;
Using Cypher’s datetime.realtime()
WITH datetime.realtime() AS output
RETURN output.epochMillis AS outputinMs, output AS datetime;
outputinMs | datetime |
---|---|
1604571467744 |
2020-11-05T10:17:47.744Z |
The following examples return the current timestamp before and after sleeping for 1000 ms using both APOC and Cypher:
apoc.date.currentTimestamp
WITH apoc.date.currentTimestamp() AS outputStart
CALL apoc.util.sleep(1000)
WITH outputStart, apoc.date.currentTimestamp() AS outputEnd
RETURN outputStart,
datetime({epochMillis: outputStart}) AS datetimeStart,
outputEnd,
datetime({epochMillis: outputEnd}) AS datetimeEnd;
Using Cypher’s datetime.realtime()
WITH datetime.realtime() AS start
CALL apoc.util.sleep(1000)
WITH outputStart, datetime.realtime() AS end
RETURN start.epochMillis AS outputStart,
start AS datetimeStart,
end.epochMillis AS outputEnd,
end AS datetimeEnd;
outputStart | datetimeStart | outputEnd | datetimeEnd |
---|---|---|---|
1604571641430 |
2020-11-05T10:20:41.430Z |
1604571642434 |
2020-11-05T10:20:42.434Z |