Description
Formats a date/time value using a simple token-based pattern. Supports common date/time tokens and optional timezone offset adjustment.Syntax
Parameters
Supported Pattern Tokens
Returns
Type: string A formatted date/time string according to the pattern. Returnsnull if the input date is invalid.
Examples
Example 1: Basic Date Formatting
Example 2: Full DateTime with Time
Example 3: Custom Format with Timezone
Example 4: Formatting Node Timestamps
Notes
- Returns
nullfor invalid date inputs - Default pattern is ISO8601-like:
'YYYY-MM-DDTHH:mm:ss[Z]' - Timezone parameter adjusts the displayed time for the given offset
- All calculations are UTC-based internally
- Milliseconds are optional in the pattern
See Also
- date.parse - Parse string to date
- date.truncate - Truncate date to specific unit
- date.toTimeZone - Convert date to timezone
Frequently Asked Questions
What format tokens does flex.date.format support?
What format tokens does flex.date.format support?
Common tokens include
yyyy (year), MM (month), dd (day), HH (hour), mm (minute), ss (second). The function uses token-based pattern formatting.Can I include a timezone offset in the format?
Can I include a timezone offset in the format?
Yes. Pass an optional timezone offset parameter to adjust the output before formatting.