2019-04-23 ISO date on macOS

To print the current date in ISO 8601 format on macOS:

  $ date +%Y-%m-%dT%H:%M:%S
  2019-04-23T14:44:46

To print it with the timezone information, append %z.

  $ date +%Y-%m-%dT%H:%M:%S%z
  2019-04-23T14:44:42+0200

Note that in the last case, you're missing the colon in the timezone bit. To correct this, we'll need to do some bash wizardry:

  $ zone=$(date +%z);datetime=$(date +%Y-%m-%dT%H:%M:%S); echo $datetime${zone:0:3}:${zone:3:2}
  2019-04-23T14:44:42+02:00