Insert Date/Time in Any Program Using Keyboard Hotkey

When you’re writing content such as technical content, news articles, etc., you may sometimes want to insert the current date or timestamp in a program or editor you’re using. In Notepad, you can add the timestamp by pressing the F5 key.

Microsoft Office Word, OneNote allows the Alt + Shift + D and Alt + Shift + T hotkey combinations to insert the current date and current time respectively.

Similarly, WordPad has the Date and time toolbar button that lets you insert the date or timestamp in your preferred format from the list of 13 choices.

insert date/time in any program - wordpad

But, if you’re using a program which doesn’t have a built-in feature to insert current date and time, you may need a third-party macro or automation tool for that purpose. With automation tools, you also have the advantage of using a single hotkey combination to insert the date or timestamp in any program.

Insert date or time in any program using keyboard hotkey

AutoHotkey is a free, open-source scripting language for Windows that allows users to easily create small to complex scripts for all kinds of tasks such as form fillers, auto-clicking, macros, etc.

  1. Download AutoHotkey and install it.
  2. Right-click on the desktop, click New and select AutoHotkey Script.
  3. Rename the script file New AutoHotkey Script.ahk to insert_date.ahk
  4. Right-click the file and choose Edit Script
  5. Remove all lines in the script and replace it with the following code:
    ^!d::
         FormatTime, CurrentDateTime,, hh:mm tt M/dd/yyyy
         SendInput, %CurrentDateTime%
    return

    insert date/time in any program - notepad .ahk editor

  6. Save the file insert_date.ahk and close the editor.
  7. Double-click to run the script. It will show up in the notification area.
  8. Now, switch to the program where you want to insert the date or timestamp.
  9. Press Ctrl + Alt + D to insert the timestamp at the current cursor position.

Script Customization

You can change the keyboard hotkey in the (1st line of the) script if you need. Here are the modifiers.

  • !   {Alt}
  • +   {Shift}
  • ^   {Ctrl}
  • #   {Winkey}

For example, for Ctrl + Alt + Shift + D, you’d use ^!+d.

For the full list of keys you can send or intercept, see AutoHotkey SendInput documentation

Without using hotkeys

If you want to insert the timestamp by typing a specific word — e.g., td, then edit the .ahk script and replace its contents with the following:

::td::
     FormatTime, CurrentDateTime,, hh:mm tt M/dd/yyyy
     SendInput, %CurrentDateTime%
return

Now, type td (and followed by a space) in any program. The words td will be replaced by the current date/timestamp. See this animation:



insert date/time in any program

Similarly, you can customize the Date or timestamp format.

insert date/time in any program - autohotkey

Date format Result
hh:mm tt M/dd/yyyy 11:26 AM 6/15/2019
hh:mm tt MM/dd/yyyy 11:26 AM 06/15/2019
hh:mm:ss tt MM/dd/yyyy 11:26:22 AM 06/15/2019
HH:mm MM/dd/yyyy 11:26 06/15/2019
HH:mm MMM/dd/yyyy 11:26 Jun/15/2019
(no formatting) 11:26 AM Saturday, June 15, 2019

See FormatTime Syntax AutoHotkey documentation for more information.

The above AutoHotkey script uses merely 1.5 MB of memory.

autohotkey task manager memory cpu usage

And you can even compile the .ahk script to a .exe file so that you don’t need to have the AutoHotkey program installed. This is especially helpful if you manage a lot of computers as part of your home or work network.


One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded Winhelponline.com in 2005.

7 thoughts on “Insert Date/Time in Any Program Using Keyboard Hotkey”

    • Adjust the format string to remove the time parameters:

      ^!d::
      FormatTime, CurrentDateTime,, M/dd/yyyy
      SendInput, %CurrentDateTime%
      return

  1. Almost what I need, so I thank you. Problem is that I am working in a WordPress form and, when I use this, nothing is inserted. I tried changing the hotkeys. It seems to be impervious to the insertion process.

    Pasting, however, does work. So I run this with notepad open and copy it, then paste it into the form. Works, though rather slow. I did modify the program so that it automatically highlights and then copies the output.

    Mainly, I would like to find a way to divorce it from needing a third program to paste the output into. I could have it open notepad, do its thing, and then close notepad,, but that would be really slow.

    Is there any way to have ahk write the output directly onto the clipboard?

    —–Paul—–

    Reply

Leave a Reply