Format Specifiers
The complete specifier table for format() and ZEpoch.parseFormat(). Literals are escaped with brackets: format('[Week] W [of] YYYY').
Uppercase F specifiers include the decimal point and omit the entire fractional component when its value is zero. Lowercase f specifiers do not include a decimal point and always emit at least one digit. Both forms remove insignificant trailing zeros. For example, 10,000,000 nanoseconds formats as .01 with FFF and 01 with fff.
| Specifier | Meaning | Example | Notes |
|---|---|---|---|
| YYYY | 4+ digit year | 2024 | 4 digits normally; signed 6-digit expanded years outside 0000..9999 |
| YY | 2-digit year (absolute) | 24 | Zero-padded to 2 digits |
| GGGG | 4+ digit ISO week year | 2024 | 4 digits normally; signed 6-digit expanded years outside 0000..9999 |
| GG | 2-digit ISO week year (absolute) | 24 | Zero-padded to 2 digits |
| EE | Era long form | Before Christ | Full era name for the current calendar |
| E | Era short form | BC | Gregorian uses AD/BC; other calendars fall back to the full era name |
| WW | Week of year (2-digit) | 03 | Zero-padded week number |
| W | Week of year (unpadded) | 3 | Unpadded week number |
| ISO Quarter (2-digit) | 01 | Zero-padded ISO quarter number | |
| Q | ISO Quarter (1..4) | 1 | Single digit ISO quarter |
| MMMM | Full month name | January | Localized month name |
| MMM | Abbreviated month name | Jan | Localized abbreviated month |
| MM | Calendar month number (2-digit) | 01 | Calendar-specific; zero-padded for positive one-digit months |
| M | Calendar month number | 1 | Calendar-specific unpadded month number |
| DAYS | Days in month | 31 | Number of days in current month |
| DDD | Day of year (3-digit) | 014 | Calendar-specific; zero-padded to 3 digits |
| DS | Day of month (1 or 2-digit) | ' 9' | 1..31, space-padded |
| DD | Day of month (2-digit) | 09 | 01..31, zero-padded |
| D | Day of month (1..31) | 9 | Unpadded day of month |
| dddd | Full weekday name | Sunday | Localized weekday full name |
| ddd | Weekday abbreviation | Sun | Localized weekday abbr |
| dd | ISO Day of week number (1=Monday..7=Sunday) | 1 | Numeric weekday |
| d | Day of week number (0=Sunday..6=Saturday) | 0 | Numeric weekday |
| hh | 12-hour (zero-padded) | 02 | 01..12, zero-padded |
| h | 12-hour (unpadded) | 2 | Unpadded 12-hour |
| HH | 24-hour (zero-padded) | 02 | 00..23 padded |
| H | 24-hour (unpadded) | 2 | Unpadded 24-hour hour |
| mm | Minutes (2-digit) | 08 | 00..59, zero-padded |
| m | Minutes (unpadded) | 8 | Unpadded minutes |
| ss | Seconds (2-digit) | 09 | 00..59, zero-padded |
| s | Seconds (unpadded) | 9 | Unpadded seconds |
| FFF | Optional nanosecond fraction | .004362713 | Includes .; up to 9 digits; empty when zero |
| FF | Optional microsecond fraction | .004362 | Includes .; up to 6 digits; empty when zero |
| F | Optional millisecond fraction | .004 | Includes .; up to 3 digits; empty when zero |
| fff | Nanosecond fraction digits | 004362713 | No decimal point; up to 9 digits; 0 when zero |
| ff | Microsecond fraction digits | 004362 | No decimal point; up to 6 digits; 0 when zero |
| f | Millisecond fraction digits | 004 | No decimal point; up to 3 digits; 0 when zero |
| A | Meridiem (locale form) | AM | Localized meridiem |
| a | Meridiem (lowercase) | am | Lowercased localized meridiem |
| OOO | Offset decorated (+-HH:mm or +-HH:mm:ss) | -05:00 | With colon, always includes minutes |
| OO | Offset standard (+-HHmm or +-HHmmss) | -0500 | Without colon, always includes minutes |
| O | Offset compact (+-HH or +-HHmm or +-HHmmss) | -05 | Omits seconds and/or minutes when zero; -0530 when non-zero |
| Z | IANA time zone name | America/New_York | Full IANA zone name |
| z | Time zone abbreviation | EST | Derived from Intl parts; runtime-dependent |
| XXXX | Epoch (nanoseconds) | 1705233600123456789 | Nanoseconds since epoch |
| XXX | Epoch (microseconds) | 1705233600123456 | Microseconds since epoch |
| XX | Epoch (milliseconds) | 1705233600123 | Milliseconds since epoch |
| X | Epoch (seconds) | 1705233600 | Seconds since epoch |
| L | Locale | en-US | Returns configured locale string |
| C | Calendar system | hebrew | Returns configured calendar name |
