Dates from UNIX timestamps in OpenOffice/LibreOffice

This is not something I discovered myself, rather it's something that I'll need every now and then when doing extemporary reports of UNIX-timestamped data. The problem is: you have a time series of data in a spreadsheet, and the time is expressed as UNIX timestamps (seconds since the epoch, 1970-01-01 00:00:00 UTC, and not taking into account leap seconds): how can you convert those timestamps in a readable date like, e.g., "01/07/2012 01:00:00"?I found a very useful suggestion in the OpenOffice community forum. As it seems, OpenOffice's "day 0" is December 12th, 1899; that implies that January 1st, 1970 is day 25569 for OpenOffice. Now, if you divide a UNIX timestamp by 86400 (the number of seconds in a normal day), that will give you the number of days between the epoch and that timestamp (and some decimal, that you can use to calculate the time of day). And if you sum that number with 25569, you have an OpenOffice day for that timestamp.

Alright, let's put all the pieces together: let's say cell A2 contains a UNIX timestamp 1341104400, then this formula

=A2/86400+25569

will return a number. And if you format that cell as a date, DD/MM/YYYY HH:MM:SS, then you'll read a pretty "01/07/2012 01:00:00" there.

Nice, isn't it? I am sure I'll be referring back to this post every once in a while 🙂

5 thoughts on “Dates from UNIX timestamps in OpenOffice/LibreOffice

  1. Pingback: Gestión de fechas en Libreoffice – Cross Forests

  2. This was useful to understand it clearly! One thing, the day 0 in Open Office or LibreOffice is not the 12th is the 30th. So correct complete date acting as “day 0” is: December 30th, 1899

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.