apoc.date.currentTimestamp

Function APOC Core

apoc.date.currentTimestamp() - returns System.currentTimeMillis() at the time it was called. The value is current throughout transaction execution, and is different from Cypher’s timestamp() function, which does not update within a transaction.

Signature

apoc.date.currentTimestamp() :: (INTEGER?)

Usage Examples

The following returns the current timestamp in ms:

WITH apoc.date.currentTimestamp() AS outputInMs
RETURN outputinMs, datetime({epochMillis: output}) AS datetime;
Table 1. Results
outputinMs datetime

1604571467744

2020-11-05T10:17:47.744Z

The following returns the current timestamp before and after sleeping for 1000 ms:

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;
Table 2. Results
outputStart datetimeStart outputEnd datetimeEnd

1604571641430

2020-11-05T10:20:41.430Z

1604571642434

2020-11-05T10:20:42.434Z