I’d expect myNewDate
to be “today”:
set myShortDate to short date string of (current date)
set myNewDate to date myShortDate
But it is weirdly not, at least on my system.
Any idea what’s going on?
I’d expect myNewDate
to be “today”:
set myShortDate to short date string of (current date)
set myNewDate to date myShortDate
But it is weirdly not, at least on my system.
Any idea what’s going on?
It might help to show us what you do get…
System version?
Hi brandelune.
Have you checked your “Date format” setting (System Settings->General->Language & Region->Date format)? I can get your script to return the wrong date by having “Region” set to “United Kingdom” and “Date format” set to “8/19/25” (or "Region set to “United States” and “Date format” set to “19/08/2025”).
But I’d expect AS to give me a “short date string” and a “date” that conform to my settings. It’s not like I’m asking it to transform anything here.
what is the value of myShortDate?
The short date string command generates a string based on the user settings that Nigel mentioned, but the date command uses AppleScript’s date determining method that has nothing to do with user settings.
For that reason I never use date string; time string or short date string commands in that way.
So would I. What I’m seeing (which you haven’t confirmed as being what you’re seeing), is probably a bug. short date string
returns results in the format set under “Date format” in System Settings, whereas when date
is followed by a short date string, the string’s interpreted as being in the format assumed from the “Region” setting.
To illustrate the point made by Nigel, the region on my Sequoia computer is United States and my date format in System Settings is 8/19/25. The OP’s script correctly returns:
I changed the date format to 19/8/25 and the OP’s script incorrectly returns:
The AppleScript Language Guide states as quoted below, so either this is a bug or the date string is considered to be incomplete information.
If you construct a date using only partial information, AppleScript fills in the missing pieces with default values. The actual format is based on the settings in System Preferences.
Without some additional information from the OP, this is all pretty much guesswork.