0

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.

3
  • 6
    What is the issue you're experiencing? Unix timstamps are offsets since 1970.
    – Kusalananda
    Mar 6, 2017 at 14:13
  • 1
    Do you want this on Unix or on Linux? They are not the same thing and, specifically, the date command is very different. Since you're using date -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?
    – terdon
    Mar 6, 2017 at 15:03
  • Perhaps you need to add 946684800 seconds?
    – Oskar Skog
    Mar 6, 2017 at 15:38

2 Answers 2

4

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.

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .