Last updated

Formatting Dates in Liquid

When working with Onboarded, you may encounter dates related to employee onboarding, such as when an employee signed a document, their date of birth, or their hiring date. To display these dates in a readable format, you can use Liquid’s date filter.

The date filter allows you to convert raw date values into user-friendly formats. This is useful when displaying dates in emails, documents, or within your onboarding platform.

How the date Filter Works

The date filter takes a date value (e.g., employee.dob) and formats it according to the specified format string.

Basic Syntax

{{ employee.signature.signed_at | date: "%B %d, %Y" }}

This would output: "February 6, 2025" (assuming the signing date was February 6, 2025).

Common Use Cases & Examples

1. Display an Employee's Date of Birth

{{ employee.dob | date: "%B %d, %Y" }}

➡️ Outputs: "July 15, 1990"

2. Show the Hire Date in a Formal Format

{{ form.hired_date | date: "%A, %B %d, %Y" }}

➡️ Outputs: "Monday, June 10, 2024"

3. Display a Signed Date with Time

{{ employee.signature.signed_at | date: "%B %d, %Y at %I:%M %p" }}

➡️ Outputs: "February 6, 2025 at 02:30 PM"

4. Show the Hire Date in a Shorter Format

{{ form.hired_date | date: "%d-%m-%Y" }}

➡️ Outputs: "10-06-2024"

5. Show Only the Year of Birth

{{ employee.dob | date: "%Y" }}

➡️ Outputs: "1990"

Date Formatting Options

Below is a reference table for Liquid date format options:

FormatDescriptionExample Output (for February 6, 2025)
%YFull year (4 digits)2025
%yShort year (last 2 digits)25
%mMonth (01-12)02
%BFull month nameFebruary
%bAbbreviated month nameFeb
%dDay of the month (01-31)06
%eDay of the month (1-31, no zero-padding)6
%AFull weekday nameThursday
%aAbbreviated weekday nameThu
%HHour (24-hour format, 00-23)14
%IHour (12-hour format, 01-12)02
%pAM or PMPM
%MMinutes (00-59)30
%SSeconds (00-59)45
%ZTime zone nameUTC
%zTime zone offset+0000

Conclusion

By using Liquid’s date filter, you can easily format onboarding-related dates in a way that is clear and professional. Whether you’re displaying hiring dates, birthdates, or document signing times, this feature ensures a polished and user-friendly experience.

For more advanced formatting options, refer to Liquid documentation.