Convert time with regex

hello,
i am using date & time function and from what I can tell, it can only return 24h with HH:mm

now I would like to apply a regex to it, for 12 hours with am pm,
I found this regex:

 /((1[0-2]|0?[1-9]):([0-5][0-9]) ?([AaPp][Mm]))/

how do I apply it to my property?

currently my expression is:
{{$node[“Date & Time1”].json[“data”]}}

would this work?
{{$node[“Date & Time1”].json[“data”].match(/((1[0-2]|0?[1-9]):([0-5][0-9]) ?([AaPp][Mm]))/)}}

Hi @Mike_Peterson

There is a way to do it with the custom format in the Date & Time node.
Format can be set with:
h = used for AM/PM times (1-12).
H = used for 24 hour times (1-24).
m = minutes
s = seconds
a = am/pm marker

ps. your Regex is used to match(or find) AM/PM formatted times.

2 Likes

can I use just
HH:mm:ss a

without the date?

Of course, you can do what ever you need :wink:

Thank you very much, worked

1 Like