Edit: using Amazon Linux:Linux ip-xx-xx-xx-xxx 3.14.44-32.39.amzn1.x86_64 #1 SMP Thu Jun 11 20:33:38 UTC 2015 x86_64 x86_64 x86_64 GNU/LinuxOutput of this command:date +%Y-%m-%d %H:%M:%S --date=2015-07-27 00:11:222015-07-27 00:11:22Output of this command:date +%Y-%m-%d %H:%M:%S --date=2015-07-27 00:11:22 + 00:052015-07-27 00:06:22Output of this command:date +%Y-%m-%d %H:%M:%S --date=2015-07-27 00:11:22 - 00:052015-07-27 00:16:22OMFG is the time flowing backwards? Or an 8th layer issue?Edit: My Amazon Linux is at UTC+00:00 while my Ubuntu local machine is at UTC-05:00. The same commands in Ubuntu show:2015-07-26 19:11:222015-07-26 19:06:222015-07-26 19:16:22respectively, so + 00:05 does not seem to be the time zone.
The arithmetic operations in bash date... are reversed?
date
According to the source of parse-datetime.y of gnulib, it seems to be a feature related to the function time_zone_hhmm.First, we cannot use your format to add seconds : date +%Y-%m-%d %H:%M:%S --date=2015-07-27 00:11:22 - 00:05:01, I'm having a parse error :date: invalid date 2015-07-27 00:11:22 - 00:05:01Then, according to the header of the time_zone_hhmm function : /* Convert a time zone expressed as HH:MM into an integer count ofminutes.  If MM is negative, then S is of the form HHMM and needsto be picked apart; otherwise, S is of the form HH.  As specified inhttp://www.opengroup.org/susv3xbd/xbd_chap08.html#tag_08_03, allowonly valid TZ range, and consider first two digits as hours, if nominutes specified.  */So, looks like you're modifing the timezone, which match the behavior of inverted add/remove time.Should you want to perform arthmetics on time, you'd better use Epoch timestamps (date +'%s') which are easier to perform calculations on. Moreover, they are based on UTC time, which does not take local timezone of the server you're working on into account.A timestamp will thus return the same result on USA, Asia or Europe. Then you use this timestamp to display human readable time, which takes the Timezone into account.Anyway, nice catch. I would never have dug in gnulib source without this nice trick !