Why won't `date` accept it's own default output?

0

On my system right now by default date outputs:

$ date
Fri 29 Jan 22:04:26 GMT 2016

However if I try to feed dates of this format back into date it results in "invalid date":

$ date -d "$(date)"
date: invalid date ‘Fri 29 Jan 22:06:14 GMT 2016’

I realise that I can manually choose a format that date will understand:

$ date -d "@$(date +%s)"
Fri 29 Jan 22:08:03 GMT 2016

But I am interested in why it is outputting a format that it won't accept back in.

Jamie Kitson

Posted 2016-01-29T22:08:56.773

Reputation: 532

Works for me with the date from coreutils 8.4. Maybe your date is buggy, or some other implementation. – jjlin – 2016-01-29T22:14:15.630

I apparently have version 8.24, does yours output the same format as mine by default? – Jamie Kitson – 2016-01-29T22:48:54.593

Same format. Works for me also on vanilla builds of coreutils 8.24 and 8.25. Maybe your Linux distro added some patches that change this behavior. – jjlin – 2016-01-29T23:28:02.740

I'm using Arch. – Jamie Kitson – 2016-01-30T00:03:27.627

I don't know what Arch does, but it should be pretty straightforward to download and build coreutils yourself and see if a vanilla build exhibits the same behavior. – jjlin – 2016-01-30T00:13:12.057

No answers