View Categories

How to Format Date and Time

3 min read

Formatting date and time is crucial for serving customers in different regions, as date and time formats vary across countries and cultures. ChitChatbot makes it easy to customize how your bot displays dates and times to match your users’ preferences.

Here’s a step-by-step guide to help you set up date and time formatting within your flows:


Step 1: Choose the Flow to Edit

Navigate to the flow where you want to format a date or time.


Step 2: Add the Action

In the flow’s block builder:

  • Select the “Action” option.
  • From the list of actions, choose “Format Date / Date & Time”.
a format data - ChitChatBot - AI Bot Building Platform

Step 3: Configure the Format

Within the Format Date / Date & Time action, do the following:

Select the Date Field

  • Choose the custom field containing the date you want to format.

Enter the Desired Format

  • In the Format field, type the pattern you want to display.
    For example, to show the date and time as 23-01-2022; 02:00 a.m, enter: d-m-Y; h-i a
  • Refer to the table below for all available formatting parameters.

Save the Formatted Date

  • Either create a new custom field or select an existing one in the “Save the formatted date to” field.

Set the Time Zone

  • You can choose whether to format the date in the page’s time zone or the user’s time zone.

Finally, click Save to apply these settings.


Formatting Parameters for Date & Time

CharacterDescriptionExample Values
Day
dDay of the month, 2 digits with leading zeros01 to 31
DShort textual representation of a day (3 letters)Mon through Sun
jDay of the month without leading zeros1 to 31
lFull textual day of the weekSunday through Saturday
NISO-8601 numeric day of the week1 (Monday) to 7 (Sunday)
SEnglish ordinal suffix (st, nd, rd, th)st, nd, rd, th
wNumeric day of the week (0 for Sunday)0 to 6
zDay of the year, starting from 00 to 365
Week
WISO-8601 week number of year01 to 53
Month
FFull textual month (January, February, etc.)January through December
mNumeric month with leading zeros01 to 12
MShort textual month (3 letters)Jan through Dec
nNumeric month without leading zeros1 to 12
tNumber of days in the given month28 to 31
Year
LLeap year indicator (1 for yes, 0 for no)0 or 1
oISO-8601 year (may differ from calendar year)1999, 2025, etc.
YFour-digit year1999, 2025
yTwo-digit year99, 25
Time
aLowercase am/pmam, pm
AUppercase AM/PMAM, PM
g12-hour format without leading zeros1 to 12
G24-hour format without leading zeros0 to 23
h12-hour format with leading zeros01 to 12
H24-hour format with leading zeros00 to 23
iMinutes with leading zeros00 to 59
sSeconds with leading zeros00 to 59
UUnix timestamp (seconds since 1970-01-01 00:00:00 GMT)e.g., 1717457692

Note:
The U format is particularly useful for math operations. For example, if you want to calculate how long a user takes to complete a quiz:

({{stop}} - {{start}}) / 60

This calculates the total time in minutes! This would be a maths operation.


Example Format

If you want to display:

23-01-2022; 02:00 am

You would use the format string:

d-m-Y; h-i a

Key Tips

✅ Double-check the time zone settings to ensure accurate local time for your users.
✅ Store the formatted date in a separate custom field for easy use in your flows.
✅ Use the formatting parameters creatively to suit your audience’s region and language.