I'm having some weird issues with GNU coreutils date v8.4 (CentOS) that aren't occurring in v8.21 (Ubuntu/Mint).
On v8.4, I get the following output (I'm in PST):
$ date --version | head -n 1
date (GNU coreutils) 8.4
$ date -d '2014-11-08'
Sat Nov 8 00:00:00 PST 2014
$ date -d '2014-11-08T00:00:00'
Fri Nov 7 09:00:00 PST 2014
I'm assuming it's trying to timezone-correct for UTC, even though I didn't request it and this behavior doesn't occur on my local Linux Mint machine.
Okay, so I'll add a timezone specifier, as specified by W3. On my machine:
$ date --version | head -n 1
date (GNU coreutils) 8.21
$ date -d '2014-11-08T00:00:00-0800'
Sat Nov 8 00:00:00 PST 2014
$ date -d '2014-11-08T00:00:00-08:00'
Sat Nov 8 00:00:00 PST 2014
Great. But on CentOS:
$ date --version | head -n 1
date (GNU coreutils) 8.4
$ date -d '2014-11-08T00:00:00-0800'
date: invalid date `2014-11-08T00:00:00-0800'
$ date -d '2014-11-08T00:00:00-08:00'
date: invalid date `2014-11-08T00:00:00-08:00'
EDIT: Another one that doesn't work, using date
's own output:
$ date -d "$(date -Ihours)"
date: invalid date `2014-11-08T13-0800'
The following does work:
$ date -d '2014-11-08 00:00:00 -08:00'
Sat Nov 8 00:00:00 PST 2014
but, due to completely unrelated requirements, I can't have any spaces in my date string.
I'm quite perplexed. I looked for recent changes to date
but didn't see anything that looks promising.
My question: How can I get date
to either not change my timezones at all (preferable), or accept timezone input from a human-readable string without spaces?