Convert Date

Overview

Convert Date transforms dates between different formats and time representations. Use this stage to convert dates from various formats, including Unix timestamps, into the required output format. It can be used to convert between human-readable dates, ISO formats, Unix timestamps, and custom date formats within a flow.

* Example flow demonstrating how Convert Date transforms a player registration date into a different date and time format and uses the converted value in the next stage.

Note: The variable names, values, criteria, and configuration used in this example are for demonstration purposes only.

Where to find it: Actions > Transformers in the stage library.

Convert Date

Where to find it: Actions > Transformers in the stage library.

Configuration

Required Fields

FieldDescriptionExample
Input Date (Original)Date value to convert (date string or Unix timestamp)2026-01-06, 1735948800, {{dateField}}
Input Format (Format)How to interpret the input date (pattern or Unix type)yyyy-MM-dd, UNIXSECOND, MM/dd/yyyy
Output Name (Output)Variable name to store converted datevariable, displayDate, timestamp
Output Format (OutputFormat)How to format the output date (pattern or Unix type)MM/dd/yyyy, UNIXSECOND, MMMM dd, yyyy

Using functions in these fields: Any value field above accepts @ functions, for example @NowSecond for the current time or @calc(...) for a calculation. 

See Flows Functions for the full list.

Unix Timestamp Types

TypeDescriptionExample
UNIXSECONDUnix timestamp in seconds1735948800
UNIXMILLIUnix timestamp in milliseconds1735948800000
UNIXMINUnix timestamp in minutes28932480

System Variables

Use these system variables in the Input Date field to work with current timestamps:

VariableFormat TypeUse Case
@NowSecondUNIXSECONDCurrent time with second precision
@NowUNIXMINCurrent time with minute precision
@UnixMillisUNIXMILLICurrent time with millisecond precision

System Variable Example

Input Date: @NowSecond Input Format: UNIXSECOND Output Format: yyyy-MM-dd HH:mm:ss Result: Converts current time to readable format

Exit Points

ExitWhen
PassDate conversion completes successfully

Important: this stage has only a Pass exit, no Error exit. If the input value does not match the Input Format (a text date that does not fit the pattern, or a non-numeric value set to a Unix type), the conversion cannot happen and the whole flow run stops at this stage. It does not pass through, and there is no error path to catch it. Always check or set the input into a known format before this stage (use Route Flow to validate, or Set Default to supply a fallback) so a bad value never reaches it.

How It Works

When executed, the stage:

  1. Parses input date - Reads date using specified input format (Unix or pattern)
  2. Converts to internal representation - Creates date object with all components
  3. Formats output - Applies output format to produce result string
  4. Stores result - Saves formatted date to output variable

Key behavior: All operations use UTC timezone. Time components default to 00:00:00 if not specified in pattern.

Java SimpleDateFormat Patterns

Date2 uses Java SimpleDateFormat patterns for custom date parsing and formatting. Use these pattern symbols to build custom date formats:

PatternComponentDescriptionExamples
GEraEra designatorAD, BC
yYearCalendar year (default)1996, 96
YYearISO week-based year2009, 09
MMonthMonth in yearSeptember, Sep, 09
wWeekWeek in year27
WWeekWeek in month2
DDayDay in year189
dDayDay in month10
FDayDay of week in month2
EDayDay name in weekTuesday, Tue
eDayDay number of week (1 = Monday, 7 = Sunday)1
aTimeAM/PM markerPM
HTimeHour in day (0–23)0
kTimeHour in day (1–24)24
KTimeHour in AM/PM (0–11)0
hTimeHour in AM/PM (1–12)12
mTimeMinute in hour30
sTimeSecond in minute55
STimeMillisecond978
zTimezoneGeneral timezonePST, GMT-08:00
ZTimezoneRFC 822 timezone-0800
XTimezoneISO 8601 timezone-08, -0800, -08:00

Pattern Letter Count Rules

The number of pattern letters changes the output. Name-based fields (month M, weekday E) switch between the full name and the short name. Number-based fields use the letter count as the minimum number of digits (zero-padded).

Month name (September shown so the length difference is clear):

  • MMMM → "September" (full name)
  • MMM → "Sep" (short name)
  • MM → "09" (two-digit number, zero-padded)
  • M → "9" (number, no leading zero)

Zero-padding on numbers: a single letter gives no leading zero, a double letter pads to two digits.

  • d → "9"  ·  dd → "09" (day)
  • yyyy → "1996"  ·  yy → "96" (year)

Match the input format to how the date is actually written. A value like 9-9-2026 needs input format d-M-yyyy; a zero-padded value like 09-09-2026 matches dd-MM-yyyy. There is no optional-digit wildcard, so the input pattern and the real text have to line up.

CRITICAL: Calendar Year vs ISO Week-Based Year

THIS DISTINCTION IS CRITICAL AND COMMONLY MISUNDERSTOOD

PatternTypeUse For
y / yyyyCalendar year99% of use cases (January 1 → December 31)
Y / YYYYISO week-based yearISO week dates only (use with w for week in year)

Why It Matters

ISO week-based year rules cause year boundaries to differ from calendar years:

  • 29 December 2025 (Monday) belongs to ISO Week 1 of 2026
  • Using YYYY on this date produces "2026" (wrong for calendar year!)
  • Using yyyy on this date produces "2025" (correct for calendar year)

Critical Rule

ALWAYS use yyyy (calendar year), NOT YYYY

Only use YYYY (ISO week-based year) together with w (week in year) for ISO week date formats like YYYY-'W'ww.

Valid vs Invalid Usage

PatternValid?Reason
yyyy-MM-dd✓ ValidCalendar year with calendar month
YYYY-'W'ww✓ ValidISO week-based year with week number
YYYY-MM-dd✗ InvalidMixing week-based year with calendar month
YYYY alone✗ InvalidWeek-based year without week number

Common Safe Pattern Combinations

Use these patterns for most date/time needs:

Use CasePatternExample Output
System dateyyyy-MM-dd2026-01-21
System datetimeyyyy-MM-dd HH:mm:ss2026-01-21 14:30:00
Display dateMMMM dd, yyyyJanuary 21, 2026
US formatMM/dd/yyyy01/21/2026
European formatdd/MM/yyyy21/01/2026
ISO week formatYYYY-'W'ww2026-W04
Time only (24h)HH:mm:ss14:30:00
Time only (12h)hh:mm a02:30 PM

Common Use Cases

1. ISO to US Format

Convert webhook date from ISO to US format for display.

Configuration:

  • Input Date: {{webhook.timestamp}}
  • Input Format: yyyy-MM-dd
  • Output Name: displayDate
  • Output Format: MM/dd/yyyy

Result:

Input:  "2026-01-06" Output: {{displayDate}} = "01/06/2026"

2. Unix Seconds to Readable Date

Convert API response Unix timestamp to readable format.

Configuration:

  • Input Date: {{apiResponse.createdAt}}
  • Input Format: UNIXSECOND
  • Output Name: createdDate
  • Output Format: MMMM dd, yyyy HH:mm:ss

Result:

Input:  "1735948800" Output: {{createdDate}} = "January 06, 2026 00:00:00"

3. User Date to Unix Timestamp

Convert user-entered date to Unix timestamp for API storage.

Configuration:

  • Input Date: {{userInput.date}}
  • Input Format: MM/dd/yyyy
  • Output Name: timestamp
  • Output Format: UNIXSECOND

Result:

Input:  "01/06/2026" Output: {{timestamp}} = "1735948800"

Best Practices

  • ✓ Use yyyy for calendar year (99% of use cases)
  • ✓ Use system variables (@NowSecond, @Now, @UnixMillis) for current timestamp
  • ✓ Match pattern to input - if input has time, include time in Format pattern
  • ✓ Test patterns first to verify expected output
  • ✓ Use UNIXSECOND for storage (timezone-independent, standard)
  • ✓ Escape special characters with quotes: yyyy-MM-dd'T'HH:mm
  • ✓ Remember Y/w relationship - if using Y (ISO week year), must also use w (week in year)

Common Mistakes

MistakeProblemFix
Using YYYY for calendar datesWrong year on week boundaries (2025-12-29 becomes 2026-12-29)Use yyyy for calendar year, not YYYY
Mixing MM (month) with mm (minutes)Pattern produces wrong outputRemember: MM = month, mm = minutes
Not zero-paddingInconsistent date formatsUse MM/dd/yyyy not M/d/yyyy for consistent padding
Missing quotes for literalsPattern parsing failsQuote special characters: yyyy-MM-dd'T'HH:mm:ss
Omitting time in patternParser fails when data includes timeIf input has time, include time components in pattern

Troubleshooting

IssueCommon CauseFix
Flow run stops at this stage (parse failure)Input Format doesn't match the actual input value, so the date can't be parsed and the run aborts (no Error exit)Verify the pattern exactly matches the input structure (include time if present); validate the input with Route Flow before this stage
Wrong output formatOutputFormat pattern incorrectTest pattern produces desired output, use built-in types for Unix
Timezone issues (date off by hours)Unix timestamp treated as local instead of UTCAll conversions use UTC - manually adjust timezone offset if needed
Year is wrongUsed YYYY instead of yyyyUse yyyy for calendar dates (not YYYY)

Do's and Don'ts

Do:

  • ✓ Use yyyy for calendar year (unless explicitly implementing ISO week dates)
  • ✓ Include time components in pattern when input data includes time
  • ✓ Use UNIXSECOND for internal storage
  • ✓ Test patterns before deploying
  • ✓ Use system variables (@NowSecond, @Now, @UnixMillis) for current time

Don't:

  • ✗ Use YYYY for calendar dates (causes wrong year on week boundaries)
  • ✗ Mix calendar and week-based patterns (don't use YYYY-MM-dd)
  • ✗ Mix MM/mm (remember: MM = month, mm = minutes)
  • ✗ Assume timezone handling (all operations are UTC)
  • ✗ Use Y without w (ISO week-based year must be paired with week number)

Limitations

  • UTC Only: All Unix timestamp conversions assume UTC. No timezone-aware conversions.
  • English Locale: Date parsing uses English locale only. Month names must be English.
  • Limited Time Precision: Supports seconds, milliseconds, and minutes only - no microseconds.

Related Stages