Automatically Converting A Date While Typing

When I type format DD-MM (14-02), I would like Keyboard Maestro to automatically convert it to: Friday, February 14.

Is this possible?

Many thanks.

Yes, it's definitely possible:

Convert Typed String to Date.kmmacros (2.3 KB)

It wasn't clear to me from your post whether you meant you literally want to type

format DD-MM (14-02)


format (DD-MM)


`format DD-MM

or just


to trigger the macro, so I used

format DD-MM

for the default trigger, but you can change that to whatever you want as long as you leave the regex intact.


Many thanks for getting back, and sorry for the lack of clarity.

I would like to type any date in short form to be converted into long form:
14-02 will give me Friday, February 14
15-02 will give me Saturday, February 15 etc

The aim being that my input format: XX-XX will trigger the macro.
For example, 14/02 wouldn't trigger the macro in this case.

Got it. That's easy then. Just delete everything besides \d\d-\d\d in the typed trigger and the macro I posted should work fine.

Many thanks.

1 Like

This gives me the day before. :frowning:

If I type 24-02, it gives me Sunday, February 23. It must be my system... :frowning:

That's…very odd. Out of curiosity, what happens if you enter values manually, like putting %ICUDateTimeFor%TIME(YEAR(),2,24)%EEEE, MMMM d% into a token text inspector? This is what I get:

I know. Very odd. I get Sunday, February 23.

That definitely doesn't seem like it should be happening. Okay, what if you make it midday specifically, like %ICUDateTimeFor%TIME(YEAR(),2,24,12,0,0)%EEEE, MMMM d%
If that works, I can only guess something's not right with your system's date and time settings (though I can't imagine what could be causing an unambiguous date to be interpreted as being one day early).

That gives me the correct Monday, February 24.

Aha, so that was it. And wouldn't you know it, it looks like this sort of negative offset is mentioned in the TIME() function's wiki page after all:

Keep in mind that TIME is in GMT and the output of %ICUDateTimeFor% is in local time, so when doing this sort of thing it is best to use midday instead of midnight:

%ICUDateTimeFor% TIME(2015, 8, 23,12,0,0) %EEE, MMM d, yyyy%

which will generally work anywhere since at midday GMT, the entire world (almost) is on the same date. Otherwise, folks with negative GMT offsets (which includes all of the Americas for example) will get the wrong result.

So now that we know that, all you have to do to fix the macro for yourself is to add the hour, minutes, and seconds:


Boom! As usual, Gabe hits a 3 at the buzzer! That indeed is the winner Sir.

Thank you for finding that information and explaining why.

1 Like

I liked this approach so much, I worked up Date from Typed String Macro for my own needs.

It can be extended to handle multiple formats (with a Help box to remind you what they are), supports any delimiter (like slashes, periods, hyphens) and minimizes digit typing (no zeroes needed). There's also a shortcut for today's date if, like me, you never remember it.

Thanks, Gabe, for the inspiration!

1 Like