You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Help with MM/DD/YYYY HH-MM-SS Shortcut

I am trying to find a way to type something like "thedate" and have it fill in as the exact time I am typing it. I have pieced together this:

set theDate to ((current date) as string)'s quoted form
# strftime man page: https://www.freebsd.org/cgi/man.cgi?query=strftime&sektion=3
set iso8601fmt to (do shell script "date -j +\"%F %X\"") as text
tell application "System Events" to theDate

But to be frank, I have no idea exactly what I have done other than having it display the correct thing when I press the run button. Can someone help me turn this into a keyboard shortcut that runs when I type "thedate"? Whether that be adjusting the code, changing settings in settings, or both :) Thank you in advance

MacBook Pro 13″, macOS 13.6

Posted on Oct 20, 2024 7:17 PM

Reply
3 replies

Oct 21, 2024 3:45 AM in response to gmirabi

Simplifying the code:


use scripting additions

display dialog ((current date) as «class isot») as string


Instead of display dialog, you could:

set iso8601fmt to ((current date) as «class isot») as string

Under what circumstances do you want to see this iso8601 date string? One could create a macOS Shortcut with an unused keyboard shortcut that could pop a dialog window displaying this iso8601 format.

Help with MM/DD/YYYY HH-MM-SS Shortcut

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.