Format date
Function: Format date
This action allows you to take an existing date and transform it into a specific text format. This is useful when you need to display dates in a user-friendly way, integrate with other systems that require a particular date format, or convert a date into a numerical timestamp.
Input
- Date: The date you want to format. This is a required input.
- Date format: (Optional) This is a text pattern that tells the system how to arrange the year, month, day, hour, minute, and second. For example,
yyyy-MM-dd HH:mm:sswould format a date like2023-01-31 12:00:00. If you leave this blank and choose "Free format", the system will use a standard date and time format.yfor year (e.g.,yyyyfor 2023)Mfor month (e.g.,MMfor 01,MMMfor Jan)dfor day (e.g.,ddfor 31)Hfor hour (0-23, e.g.,HHfor 12)mfor minute (e.g.,mmfor 00)sfor second (e.g.,ssfor 00)
- Format type: (Optional) This determines the overall style of formatting.
- Free format: Allows you to specify a custom
Date formatstring. This is the default option. - Epoch milliseconds: Converts the date into a single number representing the milliseconds that have passed since January 1, 1970, 00:00:00 UTC.
- Free format: Allows you to specify a custom
Output
- Name: The name of the variable where the formatted date will be stored. By default, this will be
FORMATTED_DATE. This variable will contain the date as a text string.
Execution Flow
Real-Life Examples
Example 1: Displaying a project deadline in a specific format
Imagine you have a project deadline stored as a date and you want to display it on a dashboard as "Day, Month DD, YYYY".
- Inputs:
- Date:
2024-03-15(March 15, 2024) - Date format:
EEEE, MMMM dd, yyyy - Format type:
Free format - Name:
ProjectDeadlineText
- Date:
- Result: The variable
ProjectDeadlineTextwill store the textFriday, March 15, 2024.
Example 2: Converting an event start time to a timestamp for an external system
You need to send an event's start time to an external analytics system that expects the time as an Epoch millisecond timestamp.
- Inputs:
- Date:
2023-10-27 14:30:00(October 27, 2023, 2:30 PM UTC) - Date format: (Leave blank)
- Format type:
Epoch milliseconds - Name:
EventTimestamp
- Date:
- Result: The variable
EventTimestampwill store a number like1698417000000.
Example 3: Formatting a user's registration date for a welcome email
When a new user registers, you want to include their registration date in a welcome email in a simple DD/MM/YYYY format.
- Inputs:
- Date:
2023-09-01(September 1, 2023) - Date format:
dd/MM/yyyy - Format type:
Free format - Name:
RegistrationDateFormatted
- Date:
- Result: The variable
RegistrationDateFormattedwill store the text01/09/2023.