apoc.temporal.format

Details

Syntax

apoc.temporal.format(temporal [, format ])

Description

Formats the given temporal value into the given time format.

Arguments

Name

Type

Description

temporal

ANY

A temporal value to be formatted.

format

STRING

The format to return the temporal value in. The default is: yyyy-MM-dd.

Returns

STRING

Usage Examples

The following formats the current date:
RETURN apoc.temporal.format( date(), 'YYYY-MM-dd') AS output;
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;
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;
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;
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;
Results
Output

"00:00:00.0131"