I need to convert a unix timestamp (number of seconds since 2000) into a standard human-readable format. I found that the command
date -d @392603388.257982
works like a charm but the default start date is 1970.
2 Answers
A linux timestamp (wiki) is counted since 1st January 1970. Where did the year 2000 come from? Is it a homework? If yes, then you could use date
but simply increase given timestamp (counted from 2000) by number of seconds that passed until year 2000 (I got it with following command: date -u +"%s" -d "1/1/2000"
).
EDIT:
Och, and look out for time zone, that's why I've added -u
switch above.
If your timestamp number is in seconds, you could just add it to 2000-01-01T00:00:00
. With GNU date that's as simple as
date -d "2001-01-01Z +$n seconds"
I've included a Z
there to indicate that your epoch is specified in Zulu (UTC) time - if your epoch is actually in local time, you should omit that.
date
command is very different. Since you're usingdate -d
, I assume you mean Linux and not Unix. If so, please edit your question and remove "UNIX" from the title since it is misleading. That said, as mentioned by Kusalananda, there is no such thing as a Unix timestamp expressed as seconds since 2000. What exactly are you trying to do?