Can I Create Macros for Inserting Date and Time?



Hello, newbie question here, thanks in advance — how can I create macros, triggered by keystroke chord combinations, that will print today's date this way:

Friday, January 11, 2019 — option-command-D
•1/11/19 — shift-control-D
1-11-19 — option-command-D

And just to let you know I at least tried something - - on the KM editor in the actions section in the search box, I typed the word "date" but it returned no results, regardless of which category I have highlighted. And the KM wiki gets into a complicated discussion of "tokens" but doesn't seem to go straight to the simplest answer.

Thanks again, cheers! -Les

Profile pictues not displaying

Hey Les,

Welcome to the forum!  :smile:

Always try searching with the search field the Keyboard Maestro Editor Help Menu – you never know what you'll find -- actions, text-tokens, functions, and menu-items...

If you haven't read this it's worth a couple of minutes of your time.

Tip: How Do I Get The Best Answer in the Shortest Time?

In answer to your question, here's a sample macro:

Date and Time -- ICU Date Construct.kmmacros (4.1 KB)

Change the keyboard shortcut to your desired chord.

The other date patterns you wanted are:

•1/11/19	⇢		•%ICUDateTime%M/dd/yy%

1-11-19		⇢		%ICUDateTime%M-dd-yy%

Keep in mind that it's generally worth searching the forum a time or two for what you need:

And it's worth looking on the wiki:



Hi Chris, thank you so much for your detailed reply. This worked the way you told me it would, very nice.

Now just one note about the above, as I use the macros that print today's date in various formats, it looks to me like something about the process makes use of the computer's regular clipboard (copy/paste) register. For example, if I have a block of text from another app, and I went to copy it and then place it in a database, including starting with today's date, using the macro here and then hitting "command-V" for paste, prints only the date, again, rather than the text I had waiting. Then I have to go back to the prior document and select and copy the text again, and then go paste it in.

Is there any way to make this work differently, so that it won't take that memory register space? Or should I just get accustomed to a slightly different workflow, go paste the date and then go back and get the text?

Thank you, Les


Hey Les,

In a word – No. The gateway for any paste action on macOS is the system clipboard and a narrow gate it is...

The only way around that is via AppleScript, and requires either the app to be appropriately AppleScriptable or for a target UI Element's value to be settable.

However the workaround for this is simple once you know about it.

Date and Time -- ICU Date Construct v1.01.kmmacros (4.5 KB)

Keep in mind that Keyboard Maestro maintains a clipboard history as well.

Clipboard History Switcher user manual section

Activate Clipboard History Switcher action

If you're not using a multi-clipboard utility you're missing out on a big productivity booster.

I use both LaunchBar's Clipboard History and Keyboard Maestro's.



Hello Chris,

Thanks for following up on this. I have been thinking about this for several days. Yesterday I had a conversation with someone who is also a Keyboard Maestro user.

Sorry to say, your reply and instruction is a bit over my head with regard to complexity. I’m a newbie with the app and way of thinking.

In conversation yesterday, my colleague said, yes of course you can make a date stamp that doesn’t take memory register, you just have to use an AppleScript.

But I’ve never done that, have no idea what that means. Is that what your example is? How would I implement that in Keyboard Maestro?

Thank you,

Les Brockmann


Hey Les,

Your friend is mistaken, unless the app you're working in is properly AppleScriptable.

Download and run my macro, it does what you want by using the clipboard and then deleting that entry from the clipboard history.



I don't know what you mean by "memory register", but if you mean the macOS Clipboard, then yes there is a way.

Easy. Use the Insert Text by Typing action


There is an option to sent the text to a specific app, which can be in the background:



But, in doing so, will it wipe and replace whatever might be in the clipboard already?

My old workflow, with QuicKeys, was 1. highlight/copy text (in Mail or whatever); 2. change to database app (or TextEdit etc.) and enter date received, using macro; 3. paste the relevant text which was waiting in the memory register.

I never found any apps that that didn’t work in, up through Mac OS 10.11, after which QuicKeys no longer worked. Which is why I’ve gone to KM.

Thank you,



Hey Les,

You could have just tested the macro to find out the answer to that.  :wink:

Keyboard Maestro keeps a clipboard history. (Clipboard History Switcher user manual section.)

The contents of the clipboard is already saved to that history.

The macro uses the clipboard, because that's the only available gateway for pasting text anywhere on macOS – and then it deletes the NEW clipboard entry and leaves the original clipboard item right where it was in the first place.


So try out the macro and see if it works the way you want it to.



Okay, sorry to be a newbie, and thanks for your patient answers.

So a “clipboard history” can be considered to be multiple macOS clipboards? Or some other register of clipboards that KM has as part of its app programming-? The primary clipboard register can keep the data that I have entered, and a date string creation can use a different register? Cool.

Okay I shall try it.

Yes I have imported it and tried it. Seems to work. Trying to understand why, but maybe it’s good enough to just have it there. Thanks for taking the time.

Can I duplicate it and change how it formats the printed date? I like to have the following, for different usages - -

Saturday, February 23, 2019



BTW this is really helping me to move forward in my understanding of KM.



Hey Les,

Yes. Although the system clipboard is static in position (so to speak) you can shuffle stuff in and out of it.

I think there's a Clipboard History macro in the default macro set, but I don't remember for certain.

Click on the “All Macros” group in the Keyboard Maestro Editor and then search for “Clipboard History”.

If you don't find one there should be one in the Macro Library – in the Keyboard Maestro Editor see:

MenuBar > Window > Macro Library


Install it if necessary and give it a keyboard shortcut if needed.

Run it, so you can see the history in action – and discover how useful the Clipboard History Switcher is.

The Insert Text by Pasting action automatically populates the system clipboard and pastes.

The Delete Past Clipboard action with clipboard 0 removes what was put into the system clipboard and the history stack pops back to where it was before the macro was run.


Look in the Keyboard Maestro Editor Help menu for:

ICU Date Format Reference

Compare that to the expression I have in my macro and against what you want to do.

If you can't figure out the formats you want in 10-15 minutes of experimenting then report back and we'll help.

Das ist gut!  :sunglasses:



:blush: .

Just splashing in to say: implementing a clipboard history manager is one of the most useful things you can do on a computer.

Data always is a string of digits.
We move data all the time. We call this "copy" and "paste".
Every time we "copy" (or "cut" — which is two operations: copy and delete) the string is saved in the system clipboard.
Every time we "copy" the system clipboard is over-written.

Like many things related to computers, it's dead simple. The system clipboard is a location that holds one string of data. The string can be very very very long — say, a video — and it can be internally complex — say, a database — or as short or shorter than a single character. The system clipboard holds one string. When you replace the content, the new string is remembered, and the old string is removed. Once removed, neither the system clipboard nor the system have any access to the old string (though the original may still be accessed by the user).

A clipboard history manager remembers and tracks each entry, allowing you to access strings copied to the system clipboard prior to the current string in the system clipboard. The system keeps one and only one string in the clipboard. The clipboard history manager keeps a stack of strings. (The stack might be limited by duration (e.g.: a week), number (e.g.: a hundred strings), or something else.)

The clipboard history manager's stack is almost always FIFO — First In, First Out. It functions as a Pez dispenser that you manually load with one candy at a time: the last candy (string) you put in is the first one that comes out.

Keyboard Maestro's clipboard history manager is excellent. Within Keyboard Maestro the stacked strings are ordinated (that is, numbered). Typical for computer ordination, the current entry is number 0, followed by 1, 2, 3, etc. That's why in one of the macros supplied above, the Keyboard Maestro Action "Delete Past Clipboard" specifies "0". "Past clipboard 0" is the string currently in the system clipboard. Once the string in position 0 is deleted, every string in the stack moves up one position, so the string that had been at position 1 is moved to position 0, which is the top of the stack (the next Pez candy to be dispensed).

Typing text creates or augments a string in the program you are using (if it accepts typed text — most do), but does not put that string in the system clipboard. Pasting text does put that string in the system clipboard. Keyboard Maestro allows you to insert text each way. The Keyboard Maestro Wiki covers this well and provides additional useful information:

Because I use LaunchBar all-day every day, I use LaunchBar's clipboard history manager. I recommend it/them.

On to your task at hand :blush: .

I insert dates all the time. I use seven or eight different formats all the time. My need is best served by having independent macros for inserting the date/time, each assigned to a relatively easy-to-remember typed-string trigger. (All my typed-string triggers start with a period (dot) character. This has served me well since there are very few instances when I type a period followed by a non-space character.) Most of these use the Action "Insert Text by Typing". Some examples below. (I have scores of similar ones, including one for each program I write about — e.g.: ".km" ➞ "Keyboard Maestro ".)

I recommend that you set these up, customized to your needs. If you use the Action "Insert Text by Typing" you won't have any turbulence in your current workflow. (Nevertheless, I can't recommend a clipboard history manager strongly enough.)

All this touches on and begins to highlight the brilliance of Keyboard Maestro. It is exceptionally well-conceived and executed.

Final disclaimer: I am just a computer user. I've never been in a computer class. I've never written a line of code (I copy and paste). What I've presented above is information that, imho, promotes a useful understanding of computers. I know the representation is not completely accurate (improvements are welcome).

Keyboard Maestro 8.2.4 “Insert "Keyboard Maestro "” Macro

Insert "Keyboard Maestro ".kmmacros (1.5 KB)

Keyboard Maestro 8.2.4 “Insert Date, Long (Tue 24 January 2012)” Macro

Insert Date- Long (Tue 24 January 2012).kmmacros (1.5 KB)

Keyboard Maestro 8.2.4 “Insert Date, Short (10.Nov.12)” Macro

Insert Date- Short (10.Nov.12).kmmacros (1.5 KB)

Keyboard Maestro 8.2.4 “Insert Date for Day b4 Yesterday, Long” Macro

Insert Date for Day b4 Yesterday- Long.kmmacros (1.4 KB)


I have a much similar setup. In my case all of my typed string text expansions are in Typinator, which I use in addition to KM because I have nearly a thousand text expansions and it offers some features not in KM. Having said that, if I did not have Typinator, I could easily create these in KM.

My naming convention for triggering text expansions is:

  1. Start the typed string abbreviation with a semicolon
  2. Followed by a 2-3 character string (which is never a space) to denote the app or use case
    (I use "'km." for my triggers for text that I use in the Keyboard Maestro app)
  3. Followed by a period
  4. Followed by a short string mnemonic which is very easy for me to remember
  5. Terminated by a space
    (I don't use any spaces in the trigger. All "words" are separated by a period.)

Example: ISO Date string for use in KM Actions:
";km.idate "
(without the quote marks)


As @Kirby_Krieger mentioned, I find using a prefix of semicolon with a suffix of space ensures I never accidently trigger the expansion, while making it very easy to type.

The key is to work out a system for yourself that is very easy for you to remember and execute.


This is my macro: %ICUDateTime%yyyy-MM-dd HH:mm:ss Z%%|%

This is what it looks like: 2019-02-27 00:46:34 +0800

This is what I think: Insert Date &Time should be more a text expansion thing but an event that needs a keyboard shortcut to trigger.

This is the reference:

Dates and Times [Keyboard Maestro Wiki]

Date and time — Representations for information interchange — Part 2: Extensions


Hey Christopher, thanks for your kind and informative answers. And thanks to others who have chimed in.

However I seem to be on an email thread where I get lots of responses. Is there any way I could get off of that thread, or at least just get it in digest form once a week or something?

Thanks very much, Les


At the bottom of the topic it tells you how you will be notified.

In your profile settings you can also control how you are notified in various ways.