Recently, I converted to using ISO-8601 formatted dates as much as possible, e.g. 2020-06-12
. As a meme, I hope this catches on. Dates written this way are internationally recognizable, no confusion over mm/dd/yy
or dd/mm/yy
. They are sortable. And, when used consistently, they are easy to search; no worries about case sensitivity, or Jun/June spellings. Don’t take my word for it, though. Randall Munroe agrees. So does GitLab.
Here's how to create a keyboard shortcut to insert the current date formatted as ISO-8601.
-
Launch Automator, and create a new Service.
-
This particular service receives no input.
-
Drag in Run AppleScript to the service.
-
The script I used to insert a date is:
on run {input, parameters}
tell application "System Events"
set _Date to (current date)
set yyymmdd to (year of _Date as text) & "-" & ¬
text -2 thru -1 of ("00" & ((month of _Date) as integer)) & "-" & ¬
text -2 thru -1 of ("00" & ((day of _Date) as integer))
keystroke yyymmdd
end tell
end run
-
Save the service and remember the name.
-
Open System Preferences > Keyboard > Shortcuts and map the service to a useful keyboard shortcut. I use
Control
+Option
+Command
+d
, because it doesn't overlap with any of my existing app shortcuts. -
If the shortcut doesn't trigger in some apps, open System Preferences > Securuty & Privacy > Accessibility and grant access to each app you want to allow to use the shortcut.