On Sat, Oct 04, 2008 at 09:48:28PM +0200, Thomas Johansson wrote:
Is there someone that can explain why I get incorrect results on centos 4.6 and 4.7 but not on centos 5.2??
test000:/% date -d "2008-10-25 +1 days" "+%Y-%m-%d" 2008-10-26 test000:/% date -d "2008-10-26 +1 days" "+%Y-%m-%d" 2008-10-26
My initial immediate guess would be daylight savings related; if in your timezone the clock goes back on the 26th then 2008-10-26 (which means 00:00) + 24 hours would only be 2008-10-26 23:00.
You can see this if you don't specify the format string
centos4.7$ date -d "2008-11-01 +1 days" Sun Nov 2 00:00:00 EDT 2008 centos4.7$ date -d "2008-11-02 +1 days" Sun Nov 2 23:00:00 EST 2008
However, in Centos5.2...
centos5.2$ date -d "2008-11-01 +1 days" Sun Nov 2 00:00:00 EDT 2008 centos5.2$ date -d "2008-11-02 +1 days" Mon Nov 3 00:00:00 EST 2008
Why the difference in behaviour, I dunno. But if this _IS_ your problem then you can specify 4am as the time to add 1 day to.
centos4.7$ date -d "2008-11-01 04:00 +1 days" "+%Y-%m-%d" 2008-11-02 centos4.7$ date -d "2008-11-02 04:00 +1 days" "+%Y-%m-%d" 2008-11-03
That'll work on both :-)