Date bug?

Johnny Rosenberg gurus.knugum at
Sat Oct 12 18:35:27 UTC 2013

$ date -d @0 +%s

Correct. ”%c” means, according to the man pages, ”seconds since 1970-01-01
00:00:00 UTC”.

$ date -d @0 +'%F %T'
1970-01-01 01:00:00

Is this correct? Is ”1970-01-01 01:00:00” the same as ”1970-01-01 00:00:00

Is my locale settings involved somehow? I live in Sweden which is
UTC+01:00, and we have summer time (DST) right now. My guess is that what I
see in my examples above is the UTC+01:00 thing.

What I want to do is to convert a time in seconds to HH:MM:SS, so I though
that I could use:
date -d @$Seconds +%T

But, for instance, when Seconds=21, I get 01:00:21, not 00:00:21.

Of course I can easily calculate this the obvious way, for instance:
$ Seconds=34567
$ HH=$((Seconds/3600))
$ MM=$((Seconds/60-HH*60))
$ SS=$((Seconds-HH*3600-MM*60))
$ printf "%g:%02g:%02g\n" $HH $MM $SS

But I still wonder if this can be done using the date command. Looks more

Johnny Rosenberg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ubuntu-users mailing list