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
- 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)
- 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.
- 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
Symbol | Hotkey 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 Format | How it Appears |
d | 1 [day] |
dd | 01 [day] |
ddd | Mon [day of the week] |
dddd | Monday [day of the week] |
M | 1 [month] |
MM | 01 [month] |
MMM | Jan [month name] |
MMMM | January [month name] |
y | 1 [year] |
yy | 01 [year] |
yyyy | 2001 [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!