apoc.temporal.format

Function APOC Core

apoc.temporal.format(input, format) | Format a temporal value

Signature

apoc.temporal.format(temporal :: ANY?, format = yyyy-MM-dd :: STRING?) :: (STRING?)

Input parameters

Name Type Default

temporal

ANY?

null

format

STRING?

yyyy-MM-dd

Usage Examples

The following formats the current date:
RETURN apoc.temporal.format( date(), 'YYYY-MM-dd') AS output;
Table 1. Results
output

"2021-01-19"

The following formats the current datetime:
RETURN apoc.temporal.format( datetime(), 'YYYY-MM-dd HH:mm:ss.SSSSZ') AS output;
Table 2. Results
output

"2021-01-19 10:57:25.2140+0000"

The following formats the current time:
RETURN apoc.temporal.format( localtime(), 'HH:mm:ss.SSSS') AS output;
Table 3. Results
output

"10:57:57.8140"

The following formats a date:
RETURN apoc.temporal.format( date( { year: 2018, month: 12, day: 10 } ), 'ISO_DATE' ) as output;
Table 4. Results
Output

"2018-12-10"

The following formats a duration:
RETURN apoc.temporal.format( duration.between( datetime.transaction(), datetime.realtime() ) , 'HH:mm:ss.SSSS') AS output;
Table 5. Results
Output

"00:00:00.0131"