By Typing "kk1230" Get "12:30 - " 24-Hour Time Formatting

I would like to write Hours without having to type ":" and " - " everytime.

for example using kk as the text expansion prefix. I type "kk1230" which automatically turns into "12:30 - "

Is this possible?

Hi OAL

I would use the typed string to trigger the macro.
And have it set to regular expression.
Using %TriggerValue% as a token, you get what is typed and can manipulate it in the macro.
See macro below.

Time in correct format Macro (v9.2)

Time in correct format.kmmacros (2.0 KB)

2 Likes

You are a legend Jimmy! Thank you very much!

1 Like

You are welcome.

1 Like

Hey Jimmy,

That works fine for 4 digit time strings, but what about 3 digits? You're missing half the day.

Nor has @OAL told us if he handles am and pm differently.

I use 24-hour time myself to avoid such confusion.

Here's a slight mod to your macro to allow for 3-digit strings. It's not possible to predict when the string will be 3 or 4 digits, so I've used [ ] as a terminator.

[ ] == One space character in the character class, so it's visible to the naked eye.

kk130 == '1:30 - ' (No quotes in the actual string ā€“ just here to show off the string.)
kk1230 == '12:30 - '

-Chris


Time in correct format @ccstone mod 2021-02-08 05-59 CST.kmmacros (2.1 KB)

1 Like

Thank you Chris. @ccstone

In my use case, the formatting is "01:30 - " and I am also not using am/pm.

However, I can definitely see your variation being useful to someone. Thanks for the input.

1 Like

Hey Orkhan,

Very good.

You've also built similar macros for the current date and time and other repeatedly used items?

dt[ ]   ==  '2021/02/08 07:15'
tm[ ]   ==  '07:16'
fd[ ]   ==  '2021-02-08' (date suitable for the Finder)
fdd[ ]  ==  '2021-02-08 ā€ŗ 07.17.51' (my date/time stamp for the Finder)

I have more than a few, but almost all of them are in Typinator instead of Keyboard Maestro ā€“ otherwise I'd post them somewhere on the forum.

Non-Date related items:

kmv[ ]   ==  'Keyboard Maestro 9.2' (Scripted retrieval of KM version.)
kmv;[ ]  ==  'Keyboard Maestro 9.2 on macOS 10.12.6' (Scripted.)
osv[ ]   ==  'macOS 10.12.6' (Scripted.)

Many, many more.

-Chris

Thank you Chris, I will definitely check these out.

Can you tell me your reson for using Typinator? An extra program instead of KM?
I didn't know Typinator and will check it out, but just wanted to get your opinion on it.

I also saw their KeyCue app before, which is also something I am going to try.

Sure. Take a look at this:

Let me know if you have any more questions.

-Chris

1 Like

As always you are thinking ahead. Thanks for bringing this to my attention.

2 Likes