What is the easiest way to get a yyyy-mm-dd hh:mm:ss timestamp hotkey on the Mac?

One option is to use a shell script or Python/Perl/Ruby script.

One option, using Python:

#!/usr/bin/env python
import time
t = time.localtime()
# yyyy-mm-dd hh:mm:ss
print '%d-%02d-%02d %02d:%02d:%02d' % (t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec)

Another, shorter, by @NReilingh, using date (shell script):

date "+%Y-%m-%d %T"

Use /Applications/Automator.app to create a Service that executes this script. Add the Run Shell Script Automator action and insert the code above. Select no input in any application and replaces selected text. Then save.

It will be placed in the Services menu which is accessible from any application's menu bar by selecting the menu with the application's name. It might look something like this when you use it:

alt text

Assign keyboard shortcuts in the Keyboard preference pane in System Preferences.

alt text


The no longer free TextExpander has a feature similar to what you want. It's an application designed for snippet insertion, e.g. for partial email templates.


TextMate is an extensible, commercial editor that allows you to easily define custom commands, again in shell or scripting languages, and assign keyboard shortcuts to them.


There's a bug in 10.7 and 10.8 where shortcuts for Automator services don't always work until the services menu has been shown from the menu bar. There's also a noticeable delay before services are run. Another option would be to assign a shortcut to a script like this:

set old to the clipboard as record
set the clipboard to (do shell script "date '+%Y-%m-%d %H:%M:%S'")
tell application "System Events" to keystroke "v" using command down
delay 0.05
set the clipboard to old

keystroke doesn't ignore held down modifier keys, so add a small delay to the start if you run the script with a shortcut that has other modifier keys than command. FastScripts waits until modifier keys are released before running scripts that contain keystroke or key code commands.


You can install a Freeware add-on called WordService that adds this functionality as a service, for which you can assign a keyboard shortcut in System Preferences -> Keyboard -> Shortcuts.

Here is an article about it from Mac OSX Tips - http://www.macosxtips.co.uk/index_files/automatically-insert-date-and-time.php

Download from http://www.devontechnologies.com/download/products.html or from App Store http://appstore.com/mac/wordservice