To insert today's date in the format yyyy.mm-dd (e.g., 2024.07-12) as plain text on a Mac, you can use one of these methods:
1. Keyboard Shortcut (Text Replacement)
Set up a custom text replacement in macOS to auto-insert the formatted date:
- Open System Settings → Keyboard → Text Replacements.
- Click + to add a new shortcut:
- Replace: Type a shortcut (e.g.,
@@date).
- With: Paste the formatted date (e.g.,
2024.07-12).
- Now, typing
@@date will auto-replace it with today’s date (but it won’t update dynamically).
2. Automator Quick Action (Dynamic Date)
Create a system-wide service to insert the current date dynamically:
- Open Automator (Applications → Utilities).
- Choose Quick Action.
- Set:
- Workflow receives: no input.
- In: any application.
- Add a "Run AppleScript" action and paste this:
on run
set theDate to do shell script "date '+%Y.%m-%d'"
tell application "System Events" to keystroke theDate
end run
- Save as "Insert Today’s Date".
- Assign a keyboard shortcut:
- Go to System Settings → Keyboard → Keyboard Shortcuts → Services.
- Find your new service under General and assign a shortcut (e.g.,
⌃⌘D).
Now, pressing the shortcut will insert the current date (e.g., 2024.07-12).
3. Terminal Command (Clipboard)
For a one-time use, run this in Terminal to copy the date to your clipboard:
date '+%Y.%m-%d' | pbcopy
Then paste (⌘V) anywhere.
4. Text Editors (Like TextEdit or Notes)
- Press
⌘⌥D in TextEdit to insert the current date (but format may vary).
- Use TextExpander or aText (third-party apps) for dynamic snippets.
Format Explained
%Y: 4-digit year (e.g., 2024).
%m: 2-digit month (e.g., 07 for July).
%d: 2-digit day (e.g., 12).
Let me know if you'd like help customizing further!