How do I convert a UNIX timestamp to libreoffice date time?

A unix timestamp is a common way to tell time using computers (see date(1) - Linux manual page and time(2) - Linux manual page). It is defined as the number of seconds since midnight on the morning of 1970 UTC. For instance, right now the time stamp is 1708341418.

How do I convert a number like 1708341418 to “2024-02-19T06:17:44” or “Mon, 19 Feb 2024 06:17:44”? (I’m in Eastern Time right now, but I don’t mind if the time is in UTC or off by a few hours.)

That is not quite precise definition of UNIX epoch :wink:

=DATE(1970;1;1) + 1708341418/60/60/24
2 Likes

You’re right! I should have said the first morning of 1970 :smiley:. Thanks for the answer!

nitpicking, should it be:
=DATE(1970;1;1) + 1708341418/60/60/24 - TIME(5;0;0)
?

Of course - unless you follow the

:wink:

the stamp itself is seconds since epoch, but the (unix)-command date converts to local-time:

shell

~ $ date --date=@1708341418  -R
Mon, 19 Feb 2024 12:16:58 +0100

~ $ date --date=@1708341418  -R -u 
Mon, 19 Feb 2024 11:16:58 +0000
# date command from OP:
# Mon, 19 Feb 2024 06:17:44”

with me: Central European Time (CET) (utc +1 hour)

1 Like

Another issue with this solution is that it doesn’t account for leap years, leap seconds, etc. Again, not an issue for me as I’m not nearly so picky about my dates at the moment, but it would be nice if LibreOffice would support this properly.

what ??

Assuming your Mon, 19 Feb 2024 06:17:44 is NOT calculated from 1708341418 but 46 seconds later from 1708341464

My mistake. I stand corrected.