Formatting date and time is possible using Formatter app in using Formatter's Format Date action.

Using Format Date, you can change the date/time format or even convert a date/time to your favorite time zone.

Where do I find OR How do I use Formatter in my Bot?

You can find Formatter while you are creating a Bot. To use Formatter, first, add a Trigger app to your Bot. Then, select Formatter from the Apps list while specifying the Action to be performed by the Bot.

Different countries have different ways of listing dates & times. The same is the case with the apps we use every day — each one of them has their own way of showing date & time.

If Stripe says that a payment has been made at 17:30:25 Aug 26, 2019, your Shopify store could say that the same order was made on Monday, 26 August 2019 at 5:30 PM.

Looking at such scenarios, let's learn how to change the date/time format.

How do I change the format of my date/time?

Before proceeding further, you need to make sure you have a trigger/action selected which has the date/time output field. This output field will be used and it's format will be changed as per your requirements.

Let's say you have a date/time field coming from Google Sheets, and you want to convert that into a specific format. In this case, your Bot should look like as shown in below video.

You would have seen, there are multiple fields available under Format Date action. Here's what they do.

Input Date/Time

This is the field where you need to specify the date/time whose format needs to be changed.

Input Format

You can optionally specify the format of the above date & time field. If you are unsure about it (or if the format option is missing in the drop-down), you can leave it as Auto Detect. The system understands a wide variety of formats, even human-readable formats like 'next Monday 5pm'.

Target Format

Select the format you wish to convert it to. In most cases, what you may want is to convert it into Standard Format (which is provided in the drop-down) so that it can be used as an input in the subsequent action. However, if you are looking for some other format not provided in the drop-down, you can choose the Use Custom Value option and provide your desired format. You can look up for the formatting options here. Look for the desired tokens for a year, month, day & time.

Target Time Zone

You can specify the different time zone, if you would like to convert your date/time to a different time zone too.

How do I convert my date/time to a different time zone?

To convert your date/time to a different time zone, you need to follow all the above steps, and ensure to make use of Target Time Zone field.

Regions from Africa, America, Asia, Europe, Indian, Pacific are available as options to choose while selecting the target time zone.

Modifying Dates

✅ Changing Date Format

Use the Formatter app 'Format Date' action to change the date format.

Add / Subtract Time

You add or subtract a certain amount of time to any data in the Output fields. For example, if you wish to add 1 day to an output field date, add ' +1d' (without quotes and with a space before the '+' )

✅ Some examples of codes you can use

  • Code for adding one hour +1h

  • Code for adding 15 minutes +15m

  • Code for adding one-day, 6 hours and 10 minutes would be +1d +6h +10m (space before each + sign)

  • Code for subtracting 5 hours would be -5h

Common issues with Date & Time Formatting

❗️ Error: Failed to parse time "xx", not in standard format "DD-MMM-YYYY" or "DD-MMM-YYYY HH:mm:ss".

This error can occur in two scenarios.

  1. When the date/time provided to the field Input Date/Time is not a valid date/time. You need to double check and ensure a valid date/time is being passed. Resolving this might not be possible in cases where you cannot control the date/time format being passed. You need to use Formatter app as per above mentioned steps in such cases.

  2. When the date/time provided to the field Input Date/Time is not a valid date/time. You need to double check and ensure a valid date/time is being passed to the Formatter, so it's able to change it's format as per your requirements.

❗️ Error: input parameters missing

This error occurs when there was no date/time provided to the field Input Date/Time. Since the field did not receive any date/time, it cannot change the format either. You'd need to double check and ensure the field Input Date/Time receives data.

❗️ My Bot ran successfully but the date/time is different from what I expected.

This can happen because of different time zones. You need to ensure to select the correct time zone in the field Target Time Zone, and this issue should be resolved.

Did this answer your question?