`date` command on OS X doesn't have ISO 8601 `-I` option?

后端 未结 9 1634

In a Bash script, I want to print the current datetime in ISO 8601 format (preferably UTC), and it seems that this should be as simple as date -I:

http://ss

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-29 19:51

    Just use normal date formatting options:

    date '+%Y-%m-%d'
    

    Edit: to include time and UTC, these are equivalent:

    date -u -Iseconds
    
    date -u '+%Y-%m-%dT%k:%M:%S%z'
    

提交回复
热议问题