Unix Timestamp to readable date

var=1686915000 (a UNIX timestamp)
How do I convert this to a readable date/time (in GMT)

Output:
Fri Jun 16 2023 11:30:00
-or-
06-16-2023 11:30

@Timothy_Treaster we support the unix timestamp as a format in the time command. You could use the time command with the at setting pointed at your variable. To move it to GMT, you'd need to use shift based on your current timezone. (+7 for me)

{variable="1686915000"}{time: ddd MMM DD YYYY h:mm; at={=datetimeparse(variable, "X")}; shift=+7h}

the "ddd MMM DD YYYY h:mm" is the format of the time being output, see here for specifics.

default behavior of the time command is the current date and time. using at= lets me set a different time.

Inside my at I'm using datetimeparse to tell it that the date I'm using is in unix timestamp ("X").

Then I'm shifting it by that 7 hours.

2 Likes

You can test it with epochconverter.com

Thank you, once again. I thought I had read all the time/date docs. I missed the UNIX "X"! I'll give you a couple of days before I ask my next question. :slight_smile:

1 Like