Writing current date to plist file using the command line I'm trying to use this command to do so:

defaults write test.plist LatestDate date "+%y-%m-%d"


where LatestDate is the key I'm modifying. The problem is, it doesn't recognize date "+%y-%m-%d" as what I'm trying to write to the key, and when I put it in quotes it simply writes that text, not the date to the key.

How should I go about doing this?
In defaults, date is just an option, not the actual date command. You need to actually pass the date.

defaults write test.plist LatestDate "$(date +'%Y-%m-%d %H:%M:%S +0000')"