Why the discrepancy in date?

Nils Kassube kassube at gmx.net
Sun Jan 8 16:09:48 UTC 2012


Dotan Cohen wrote:
> On Sun, Jan 8, 2012 at 14:06, Nils Kassube <kassube at gmx.net> wrote:
> >> However, for dates in the past they do not:
> >> ✈saturn:~$ date +%s -d 2006-12-31t22:00
> >> 1167577200
> > 
> > Interesting - why do you use "t" instead of " " as a separator
> > between date and time?
> 
> Because then I do not need the quotes. It is also ISO standard 8601:
> http://en.wikipedia.org/wiki/ISO_8601

Ah, that's the reason - I didn't know about that standard.

> > So to me it looks like your "t" separator makes the date command
> > use the time zone UTC+7 intead of your local time zone.
> > Furthermore, if I specify a time zone together with your "t"
> > separator, date complains about an invalid date:
> > 
> > ~/ > LC_ALL=C date +%s -d "2006-12-31t22:00 UTC"
> > date: invalid date `2006-12-31t22:00 UTC'
> 
> Even specifying UTC (that is the Z timezone) doesn't help:
> ✈saturn:~$ date +%s -d "2006-12-31 22:00Z"
> 1167602400
> ✈saturn:~$ date -d @1167602400
> Mon Jan  1 00:00:00 IST 2007

But that looks correct to me - if IST = UTC+2, then "2006-12-31 22:00Z" 
is the same as "Mon Jan  1 00:00:00 IST 2007", isn't it?

> I do not believe that there should be a difference when using the T
> separator.

Agreed, it seems there is a bug in the date command. When it reads that 
"t" separator it shouldn't take it as a time zone.


Nils




More information about the ubuntu-users mailing list