Skip to main content

Format Time

Converts a date/time value from one format to another. This node is essential for transforming date/time strings to match different system requirements or human-readable formats.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Input

  • Time - The input date/time value to format. Must be formatted according to the In Layout option.

Output

  • Formatted Time - The date/time value converted to the output format.

Options

  • In Layout - The format of the input date/time. Options include:

    • ANSIC - Mon Jan 2 15:04:05 2006
    • UnixDate - Mon Jan 2 15:04:05 MST 2006
    • RubyDate - Mon Jan 02 15:04:05 -0700 2006
    • RFC822 - 02 Jan 06 15:04 MST
    • RFC822Z - 02 Jan 06 15:04 -0700
    • RFC850 - Monday, 02-Jan-06 15:04:05 MST
    • RFC1123 - Mon, 02 Jan 2006 15:04:05 MST
    • RFC1123Z - Mon, 02 Jan 2006 15:04:05 -0700
    • RFC3339 - 2006-01-02T15:04:05-07:00 (default, ISO 8601)
    • RFC3339Nano - 2006-01-02T15:04:05.000000000-07:00
    • Custom - Define a custom input format
  • Custom In Layout - Custom format string for parsing the input time. Only used when In Layout is set to "Custom".

  • Out Layout - The desired output format. Same options as In Layout.

  • Custom Out Layout - Custom format string for the output time. Only used when Out Layout is set to "Custom".

How It Works

The Format Time node converts date/time strings between different formats by:

  1. Parsing the input time string according to the In Layout format
  2. Extracting the date/time components
  3. Reformatting the date/time according to the Out Layout format
  4. Outputting the converted time string

The conversion preserves the actual date/time value; only the string representation changes.

Use Cases

API Integration

  • Convert timestamps to API-specific formats
  • Transform database timestamps to REST API format
  • Parse API responses into readable formats

Data Processing

  • Standardize date formats from multiple sources
  • Convert legacy system formats to modern standards
  • Prepare timestamps for database insertion

User Interface

  • Convert system timestamps to human-readable formats
  • Format dates for reports and dashboards
  • Localize date/time displays

File Operations

  • Format timestamps for log files
  • Create standardized filename timestamps
  • Parse timestamps from file metadata

Examples

Example 1: ISO 8601 to Human-Readable

Time: 2024-03-15T14:30:00Z
In Layout: RFC3339
Out Layout: Custom
Custom Out Layout: Monday, January 02, 2006 at 3:04 PM
Output: Friday, March 15, 2024 at 2:30 PM

Example 2: Convert to Filename-Safe Format

Time: 2024-03-15T14:30:45Z
In Layout: RFC3339
Out Layout: Custom
Custom Out Layout: 2006-01-02_15-04-05
Output: 2024-03-15_14-30-45

Example 3: Unix Date to RFC3339

Time: Fri Mar 15 14:30:00 UTC 2024
In Layout: UnixDate
Out Layout: RFC3339
Output: 2024-03-15T14:30:00Z

Example 4: Add Milliseconds to Display

Time: 2024-03-15T14:30:00Z
In Layout: RFC3339
Out Layout: RFC3339Nano
Output: 2024-03-15T14:30:00.000000000Z

Example 5: Custom Input to Standard Format

Time: 15/03/2024 14:30
In Layout: Custom
Custom In Layout: 02/01/2006 15:04
Out Layout: RFC3339
Output: 2024-03-15T14:30:00Z

Example 6: Database Format Conversion

Time: 2024-03-15 14:30:45
In Layout: Custom
Custom In Layout: 2006-01-02 15:04:05
Out Layout: RFC3339
Output: 2024-03-15T14:30:45Z

Custom Format Reference

When using custom layouts, use these Go time format tokens:

ComponentTokenExample
Year (4-digit)20062024
Year (2-digit)0624
Month (numeric)0103
Month (name)JanuaryMarch
Month (abbr)JanMar
Day0215
Day (unpadded)215
WeekdayMondayFriday
Weekday (abbr)MonFri
Hour (24h)1514
Hour (12h)0302
AM/PMPMPM
Minute0430
Second0545
Millisecond.000.123
Microsecond.000000.123456
Nanosecond.000000000.123456789
Timezone offset-07:00+00:00
Timezone (MST)MSTUTC

Workflow Example

Parse Log Timestamp and Convert for Database

  1. Extract timestamp from log file: Mar 15 14:30:00
  2. Use Format Time node:
    • In Layout: Custom
    • Custom In Layout: Jan 02 15:04:05
    • Out Layout: RFC3339
  3. Store formatted timestamp in database

Convert API Response to Display Format

  1. Receive API timestamp: 2024-03-15T14:30:00Z
  2. Use Format Time node:
    • In Layout: RFC3339
    • Out Layout: Custom
    • Custom Out Layout: 02/01/2006 3:04 PM
  3. Display to user: 15/03/2024 2:30 PM

Tips for Effective Use

  • Match Input Format Exactly - Ensure In Layout matches your input string precisely
  • Test Custom Formats - Always test custom formats with sample data before production use
  • Use Standard Formats - Prefer RFC3339 for internal operations and data storage
  • Preserve Timezone Info - Use formats with timezone information (RFC3339, RFC822Z) to avoid ambiguity
  • Filename Safety - When creating filenames, avoid : characters; use - or _ instead
  • Year Clarity - Use 4-digit years (2006) to avoid Y2K-style issues
  • Leading Zeros - Use 01, 02 for padded values; use 1, 2 for unpadded

Common Errors and Solutions

Error: "failed to parse input time"

  • Cause: Input time format doesn't match the In Layout specification
  • Solution: Verify the input format matches the In Layout exactly, including spacing and separators

Error: "custom in layout string is empty"

  • Cause: In Layout set to "Custom" but no custom format provided
  • Solution: Either provide a Custom In Layout string or select a predefined layout

Error: "custom out layout string is empty"

  • Cause: Out Layout set to "Custom" but no custom format provided
  • Solution: Either provide a Custom Out Layout string or select a predefined layout

Error: "invalid custom format string"

  • Cause: Custom format uses invalid tokens or syntax
  • Solution: Use valid Go time format tokens (see Custom Format Reference table above)

Incorrect output format

  • Cause: Wrong format tokens used in custom layout
  • Solution: Review the format reference and ensure tokens match your intended output

Important Notes

  • The conversion preserves the actual moment in time; only the string representation changes
  • Timezone information is preserved from input to output when both formats support it
  • If converting from a format without timezone to one with timezone, the system uses UTC
  • Month and day names depend on system locale settings
  • Be careful with 12-hour formats (03) vs 24-hour formats (15) to avoid AM/PM confusion
  • Leading zeros in the format pattern determine whether output values are padded
  • Now - Get current time in a specific format
  • Convert Timezone - Change timezone while formatting
  • Split Date - Extract individual date components
  • Add Time - Perform calculations on formatted dates