How to format time from AM PM to 24 hours time?

I am getting the data from the webhook in this format “1:00 PM”, “2:30 PM”. But further in the automation I need to use the time in the format “13:00” and “14:30”

  • I didn’t find how to do it with Date/Time functions, maybe there is some module?

I created a little formula that helped me with this.

{{if(contains(1.appointment.only_end_time.string; “AM”); 0 + first(split(1.appointment.only_end_time.string; space)); (parseNumber(first(split(first(split(1.appointment.only_end_time.string; space)); “:”))) + parseNumber(12)) + “:” + last(split(first(split(1.appointment.only_end_time.string; space)); “:”)))}}

It’s not perfect, because it doesn’t work from 12:00 AM, but in my case it’s enough.

There is a “format date” function. Use function in here: formatDate(your.variable; HH)

Use this document for further reference.

Princy Jain
Make consultant,
For consulting support: Follow up Automated

2 Likes

According to the Tokens you can use to parse a date variable, you can use h:mm A.

According to the Tokens you can use to format a date variable, you can use HH:mm.

e.g.:

{{ formatDate(parseDate(1.appointment.only_end_time.string; "h:mm A"); "HH:mm") }}

1:00 PM

Screenshot_2024-04-16_110450

Screenshot_2024-04-16_110456

12:00 AM

Screenshot_2024-04-16_110413

12:00 PM

Screenshot_2024-04-16_110434

For more information, see

Links

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

General

Help Center Basics

Articles & Videos

3 Likes