Pipes Reference: Date and Time Pipes
Pipes used for time-based comparison and formatting on date values.
Pipes used for date manipulation, time-based comparison, and formatting on date values.
This section defines Pipes used for date manipulation, time-based comparison, and formatting on date values. This includes:
currentDateparseISODatetoISOStringaddTimetoUnixTimeformatDateDistanceToNowisFutureisPastfilterIsPastfilterIsFuture
currentDate
- Usage Syntax:
{{ currentDate }} - Evaluates to: Date
- Description: The currentDate pipe returns the current system date and time as a JavaScript Date object.
- Equivalent to
new Date()in JavaScript orDateTime.now()in Luxon. - Useful for:
- Timestamping user actions or generating "created at" values.
- Comparing dates to determine if events are in the past or future.
- Calculating time differences or relative dates.
- Equivalent to
- Parameters: This pipe does not accept additional parameters.
- Returns:
Date: A JavaScript Date object representing the current moment.
- Example 1: Get Current Date
-
{{ currentDate }} - Output: Date object for current moment (e.g., 2026-01-27T19:30:00Z)
-
- Example 2: Format current date to ISO string
{{ currentDate | toISOString }}- Output: "2026-01-27T19:30:00.000Z"
- Notes:
- Returns a Date object, not a string. Use formatting pipes like toISOString or formatDateDistanceToNow for display.
- Time reflects the system time of the device or server executing the FQL expression.
parseISODate
- Usage Syntax:
{{ inputString | parseISODate }} - Evaluates to:
Date - Description: The
parseISODatepipe attempts to parse a valid ISO-8601 date string into a JavaScript Date object. - Useful for:
- Preparing raw date strings for formatting, comparison, or calendar logic.
- Only valid ISO-8601 formatted strings will be successfully parsed.
- If parsing fails or results in an invalid date, the pipe will return
!error.
- Parameters: This pipe does not accept additional parameters.
- Returns:
Date: A JavaScript Date object created from the input ISO string. Returns!erroron failure.
- Example 1: Valid ISO date string
{{ '2023-12-25T10:00:00Z' | parseISODate; }}- Output: Date object representing December 25, 2023 at 10:00 UTC
- Example 2: Adding a toString pipe
{{ '2023-12-25T10:00:00Z' | parseISODate | toString; }}- Output: "2023-12-25T10:00:00.00Z"
- Notes:
- Strictly requires ISO-8601 formatted input (e.g.,
YYYY-MM-DDorYYYY-MM-DDTHH:mm:ssZ). - Pipe output is a native JavaScript Date, which can be passed to formatting or comparison pipes.
- Strictly requires ISO-8601 formatted input (e.g.,
toISOString
- Usage Syntax:
{{ inputDate | toISOString }} - Evaluates to: string
- Description: The toISOString pipe converts a Date object into an ISO 8601 formatted string, always in UTC timezone.
- Equivalent to JavaScript's native
Date.prototype.toISOString()method. - Returns format:
YYYY-MM-DDTHH:mm:ss.sssZ(24 characters with milliseconds). - The
Zsuffix indicates UTC timezone. - Useful for:
- Storing dates in APIs or databases that require ISO format.
- Ensuring consistent date representation across timezones.
- Creating sortable date strings.
- Equivalent to JavaScript's native
- Parameters: This pipe does not accept additional parameters.
- Returns:
string: An ISO 8601 formatted date string in UTC timezone. Returns !error if input is not a valid Date.
- Example 1: Convert current date to ISO string
{{ currentDate | toISOString }}- Output: "2026-01-27T19:30:00.000Z"
- Example 2: Convert parsed date to ISO string
{{ '2023-12-25T10:00:00Z' | parseISODate | toISOString }}- Output: "2023-12-25T10:00:00.000Z"
- Notes:
- Input must be a valid Date object.
- Output is always in UTC timezone regardless of local timezone.
- This is the inverse operation of parseISODate.
addTime
- Usage Syntax:
{{ inputDate | addTime: seconds }} - Evaluates to: Date
- Description: The addTime pipe adds a specified number of seconds to a Date object and returns a new Date.
- Accepts positive values to add time into the future.
- Accepts negative values to subtract time into the past.
- Equivalent to
add()in date-fns/Day.js orplus()in Luxon. - Useful for:
- Calculating future expiration dates or deadlines.
- Computing "X seconds from now" timestamps.
- Adjusting dates for time-based logic.
- Parameters:
- seconds:
- Type: number
- Required: Yes
- Description: The number of seconds to add to the input date. Use negative values to subtract time.
- Returns:
- Date: A new Date object with the specified seconds added. Returns !error if input is not a valid Date or seconds is not a number.
- Example 1: Add 1 hour (3600 seconds) to current date
- {{ currentDate | addTime: 3600 | toISOString }}
- Output: Current time + 1 hour in ISO format
- Example 2: Subtract 1 day (86400 seconds)
{{ '2026-01-27T12:00:00Z' | parseISODate | addTime: -86400 | toISOString }}- Output: "2026-01-26T12:00:00.000Z"
- Example 3: Add 30 days to a date
{{ orderDate | addTime: 2592000 }}- Output: Date object 30 days later (30 * 24 * 60 * 60 = 2,592,000 seconds)
- Notes:
- Input must be a valid Date object.
- Time is specified in seconds, not milliseconds.
- Common conversions: 1 minute = 60s, 1 hour = 3600s, 1 day = 86400s, 30 days = 2592000s.
- Returns a new Date object; does not mutate the original.
toUnixTime
- Usage Syntax:
{{ inputDate | toUnixTime }} - Evaluates to: string
- Description: The toUnixTime pipe converts a Date object into a Unix timestamp string representing the number of seconds since January 1, 1970 UTC (the Unix epoch).
- Equivalent to
getUnixTime()in date-fns,unix()in Moment.js/Day.js, ortoSeconds()in Luxon. - Returns seconds, not milliseconds (unlike JavaScript's native
Date.getTime()which returns milliseconds). - Useful for:
- Storing dates as integers in databases or APIs.
- Performing date calculations using simple arithmetic.
- Interfacing with systems that expect Unix timestamps.
- Equivalent to
- Parameters: This pipe does not accept additional parameters.
- Returns:
- string: A Unix timestamp string representing seconds since the Unix epoch. Returns !error if input is not a valid Date.
- Example 1: Convert current date to Unix timestamps
{{ currentDate | toUnixTime }}- Output: "1737998400" (seconds since Jan 1, 1970)
- Example 2: Convert parsed ISO date to Unix timestamp
{{ '2023-12-25T10:00:00Z' | parseISODate | toUnixTime }}- Output: "1703502000"
- Notes:
- Returns seconds since the Unix epoch, not milliseconds.
- To convert to milliseconds (JavaScript standard), multiply by 1000.
- Input must be a valid Date object.
- The Unix epoch is January 1, 1970, 00:00:00 UTC.
formatDateDistanceToNow
- Usage Syntax:
{{ inputDate | formatDateDistanceToNow }} - Evaluates to:
string - Description: The
formatDateDistanceToNowpipe formats a given Date object into a relative, human-readable string that describes how long ago (or in the future) that date is from the current moment. - Outputs strings like:
"less than a minute ago","3 days ago","in 2 hours". - Useful for:
- User-friendly timestamps, activity feeds, or content freshness indicators.
- Outputs strings like:
- Parameters: This pipe does not accept additional parameters.
- Returns:
string: A relative time string describing how far the input date is from "now".
- Example 1: A recent timestamp
{{ '2023-12-25T10:00:00Z' | parseISODate | formatDateDistanceToNow; }}- Output: '4 months ago' (depending on current date)
- Example 2: A date in the future
{{ '2036-10-10' | formatDateDistanceToNow; }}- Output: "in 1 second ago"
- Notes:
- Input must be a valid Date object (or a string that can be parsed to one using
parseISODate). - Future dates not fully supported at this time.
- Input must be a valid Date object (or a string that can be parsed to one using
isFuture
- Usage Syntax: {{ inputDate | isFuture }}
- Evaluates to:
boolean - Description: The
isFuturepipe checks if the input Date object is after the current moment in time. - Returns
trueif the date is in the future. - Returns
falseif the date is in the past or equal to now. - Useful for:
- Filtering upcoming events, deadlines, or scheduled tasks.
- Returns
- Parameters: This pipe does not accept additional parameters.
- Returns:
boolean:trueif the input date is in the future; otherwise,false. Returns!erroris input is not a valid Date.
- Example: Date in the past
{{ '2020-01-01T00:00:00Z' | parseISODate | isFuture; }}- Output: false
- Notes:
- Input must be a valid Date object (or be piped from something like
parseISODate). - Often used for visibility conditions or scheduling logic.
- Input must be a valid Date object (or be piped from something like
isPast
- Usage Syntax:
{{ inputDate | isPast }} - Evaluates to:
boolean - Description: The
isPastpipe checks whether the input Date object is before the current moment in time. - Returns
trueif the input date is in the past. - Returns
falseif the input date is now or in the future. - Useful for:
- Evaluating expired deadlines, completed events, or archival logic.
- Returns
- Parameters: This pipe does not accept additional parameters.
- Returns:
boolean:trueif the input date is in the past; otherwise,false. Returns!erroris input is not a valid Date.
- Example: Date in the Future
{{ '2999-12-31T23:59:59Z' | parseISODate | isPast; }}- Output: false
- Notes:
- Input must be a valid Date object (or piped from something like
parseISODate).
- Input must be a valid Date object (or piped from something like
filterIsPast
- Usage Syntax:
{{ inputArray | filterIsPast: 'path': 'to': 'dateField' }} - Evaluates to:
any[] - Description: The
filterIsPastpipe filters an array of objects, retaining only those whose date value at the specified path is in the past relative to the current time. - Evaluates each item by accessing the Date value at the given path.
- Retains only those items where the resolved date is earlier than now.
- Useful for:
- Filtering expired items, past events, or archival content in data sets.
- Parameters:
...path:- Type:
string[] - Required: Yes
- Description: One or more keys that resolve to a nested date field.
- Type:
- Returns:
any[]: A filtered array containing only items with a date (at the specified path) that is in the past.
- Example 1: Filter past events by date field
[{ date: '2022-01-01' }, { date: '2999-01-01' }]{{ events | filterIsPast: 'date' }}- Output: [{ date: '2022-01-01' }]
- Example 2: Filter with nested path
[{ meta: { timestamp: '2023-01-01T10:00:00Z' } }, ...]{{ records | filterIsPast: 'meta': 'timestamp' }}- Only records where meta.timestamp is in the past
- Notes:
- Dates are parsed using ISO-8601 format which is required.
- If the resolved value is not a valid date, the item will be excluded.
filterIsFuture
- Usage Syntax:
{{ inputArray | filterIsFuture: 'path': 'to': 'dateField' }} - Evaluates to:
any[] - Description: The
filterIsFuturepipe filters an array of objects, retaining only those whose date value at the specified path is in the future relative to the current time. - Retains only items where the resolved date is later than now.
- Useful for:
- Filtering upcoming events, pending deadlines, or scheduled launches.
- Parameters:
...path:- Type:
string[] - Required: Yes
- Description: One or more keys that resolve to a nested date field.
- Type:
- Returns:
any[]: A filtered array containing only items with a date (at the specified path) that is in the future.
- Example 1: Filter future events by top-level date
[{ date: '2025-01-01' }, { date: '2020-01-01' }]{{ events | filterIsFuture: 'date' }}- Output: [{ date: '2025-01-01' }]
- Example 2: Filter future records by nested timestamp
[{ meta: { timestamp: '2099-12-31T23:59:59Z' } }, ...]{{ records | filterIsFuture: 'meta': 'timestamp' }}- Output: Only records where meta.timestamp is in the future
- Notes:
- Dates are parsed using ISO-8601 format which is required.
- If the path does not resolve to a valid date, the item is excluded.
Did this answer your question?
