Reputation:
I need to decrease 10 minutes to a given date :
givenDate = 2017-11-07 19:20:37
when executing :
newDate=$(date +'%Y-%m-%d %T' --date="$givenDate - 10 minutes")
echo $newDate
I get :
2017-11-08 06:21:37
instead of
2017-11-07 19:10:37
Please Help. Thanks you.
Upvotes: 2
Views: 112
Reputation: 3141
date
is waiting for date in format "Sun, 29 Feb 2004 16:21:42 -0800", so your "- 10 minutes" appending is treated as timezone + 1 minute.
So, add your timezone to the reference date:
$ givenDate="2017-11-07 19:20:37 $(date +%:::z)"
Upvotes: 3