Issue
Well I can get a current ISO-8601 time with date +"%Y-%m-%1dT%H:%M:%S%z"
command in Bash.
The output was 2022-09-19T00:33:55+0900
!
However, I want to get the yesterday since that command output.
I mean I want to get the output like 2022-09-18T00:33:55+0900
Can anyone help me?
Solution
Use the --date
option, like this:
date --date="yesterday" +"%Y-%m-%1dT%H:%M:%S%z"
Note that instead of writing out that whole format string, you can use -Iseconds
, like this:
date --date="yesterday" -Iseconds
Answered By - Moshe Katz Answer Checked By - Clifford M. (WPSolving Volunteer)