I have a bash script which is supposed to increment a timestamp by 1 day to echo the next 5 days from the timestamp, however when it is run it produces the wrong output and has subtracted one hour instead.
Script
#!/bin/bash
TIME_STAMP="2023-06-03 06:21:33"
for i in {1..5}
do
NEXT_DATE=$(date "+%Y-%d-%m %H:%M:%S" -d "$TIME_STAMP +$i day")
echo $NEXT_DATE
done
Output
2023-04-06 06:21:33
2023-04-06 05:21:33
2023-04-06 04:21:33
2023-04-06 03:21:33
2023-04-06 02:21:33
As far as I can tell the date format is correct so I've got absouletly no idea why it isn't working correctly. If there's an easier way to do this I'd love to hear it!