Convert unix epoch time to readable format

I was creating a macro that got the modification date for a file, and it comes in as the Unix epoch time (localized for my time zone). That's great, I understand epoch time and why it's used, etc.

I thought it'd be trivial to convert that epoch time to some readable format in KM. But no (at least not for me); after 30 minutes of frustration, here's what I wound up doing:

Execute shell script to variable:

$datestring = localtime($ENV{KMVAR_UnixTime});
print $datestring;

This worked great, and I was on my way. But what's the right way to do it, when the time value is stored in a variable? I'm pretty sure I should be using ICUDateTimeFor, but I could not make anything work. I know you can't reference (easily, at least) a variable in the token, so how am I supposed to be doing this?


A post was merged into an existing topic: Convert Epoch Time to Human Readable (Prefer PST)