For macOS, the date utility doesn't give the right information. You need to install GNU date utility.
brew install coreutilsHomebrew will install the utility as gdate instead of date, which leaves the original date untouched and available.
gdate has an --iso-8601 option available, but it doesn't give a format that strictly follows the ISO 8601 standard, as far as I can determine. I find it better to explicitly state the format with: