Subject: linux date arithmetic

From: Stefan Karamuz <[email-masked]>
Date: Wed, 28 Mar 2012 14:39:11 +0200

Please check the 2 linux commands:

date -d "$(date +%F\ %H:%M:%S)" +%F\ %H:%M:%S
date -d "$(date +%F\ %H:%M:%S) + 1 minute" +%F\ %H:%M:%S

It's very confusing, because the results of the two commands differ in 
one hour and one minute, except of one minute only.

[~]$ date -d "$(date +%F\ %H:%M)" +%F\ %H:%M:%S
2012-03-28 14:06:00

... and after a few seconds:

[~]$ date -d "$(date +%F\ %H:%M:%S) + 1 minute" +%F\ %H:%M:%S
2012-03-28 15:07:20

It's a bug or I don't understand something?

The systems tested include:

Fedora 16
Centos 6.2
Debian *6.0.4

*Best Regards,

     Stefan Karamuz