@coordinated - I really like your AppleScript; nice work. I've got one that does the same, but is much less eloquent, so I'm learning a lot from yours.
My use case appears to be exactly the same as yours. I use Obsidian on iPad rather exclusively these days and all of my markdown files start with the date format you're using. I too have been looking to automate the process so that it runs just after midnight and is available across all of my Apple products, but I can't crack the code on logging in for the GUI interaction piece. So far I've, unsuccessfully or partially-successfully, tried:
Sadly, none of these are doing the trick. I even tried implementing auto-login for a bit, but quickly reverted when that didn't resolve the inability to login unattended.
I just can't imagine that there's not an easier way to automate the process in this day & age. I will keep poking at the automation part, but for now I'm saddled with stumbling down to my laptop, logging in and kicking off my AppleScript to update my Settings/General/Keyboard/Text entries.