Hotkey to Insert Today’s Date

NOTE: This solution only works in Windows.

Many programs have keyboard shortcuts that allow you to quickly put in the current date. Notepad uses F5, Word and OneNote use SHIFT+ALT+d, and Excel uses CTRL+; (which I am partial to). But wouldn’t it be great if it was the same across all programs? Using Authotkey, you can setup a hotkey of your choice to insert the current date and it will work across all programs!

AutoHotkey is a free, open-source scripting language that is very simple and quick to get setup and working with immediately. Visit Running Your First AutoHotkey Script for how to install AHK and run a script.

HOTKEY TO INSERT DATE

I preferred to keep the hotkey characters that Excel uses to insert today’s date: CTRL+;. You can change this to whatever key combination you prefer though. Here is the code you can copy/paste into your script:

^`;::
FormatTime, CurrentDateTime,, dd/MM/yy
SendInput %CurrentDateTime%
return

That’s it! Once you run the script (double-click on the AHK file to run), anytime you press CTRL+; it will output today’s date in any program.

HOW IT WORKS

^`;::
FormatTime, CurrentDateTime,, dd/MM/yy
SendInput %CurrentDateTime%
return
  1. The first line is your hotkey character definition, which ends with ::
    • ^ is the CTRL key
    • `; is the ; character (; has a special meaning to AHK to add a comment, so you must include a backtick ` here)
  2. FormatTime is a built-in AHK command that will output a formatted local date/time to a variable name you specify, in our case, CurrentDateTime.
  3. We then send the formatted date that is in our variable, CurrentDateTime, by using SendInput %CurrentDateTime%.

CONFIGURING THE HOTKEY TO YOUR DESIRE

Changing the Hotkey Characters

SymbolHotkey Modifier
#WIN (Windows Logo Key)
!ALT
^CTRL
+SHIFT

You can replace the ^`; (CTRL+;) in the script to whatever keys you would like to trigger your hotkey with. If you prefer Word’s version of using ALT+SHIFT+d, you would have:

!+d::
FormatTime, CurrentDateTime,, dd/MM/yy
SendInput %CurrentDateTime%
return

Changing the Date Format

Date FormatHow it Appears
d1 [day]
dd01 [day]
dddMon [day of the week]
ddddMonday [day of the week]
M1 [month]
MM01 [month]
MMMJan [month name]
MMMMJanuary [month name]
y1 [year]
yy01 [year]
yyyy2001 [year]

You can change the format of the date as well. For complete options, check out the details from AHK’s Date Formats details from the FormatTime command page.

To change the format, modify the bold dd/MM/yy section of the script to how you would like it formatted.

^`;::
FormatTime, CurrentDateTime,, dd/MM/yy
SendInput %CurrentDateTime%
return

I found I use this way more often than I ever would have expected. Now, go and conquer the day (now that you can quickly type it)!

HAPPY SCRIPTING!