More > JRiver Media Center 31 for Windows

Function to translate Unix timestamp to Date?

(1/1)

macky88:
I am no expert here, but I a have been wracking my brain for way to convert a unix timestamp to a human readable Date within JRiver. I've been trying to create a custom library field with a calculated function, but I am lost at this point.

The unix timestamp is in the filename, which I can isolate, but I cannot for the life of me figure out what combination of functions I can use to convert this to a date. I'm not even sure it's possible, but I feel like some maths could get me there, my brain is just fried thinking about it!

Tried searching, but now I am here!

marko:
Have you tried the formatdate() function?
https://wiki.jriver.com/index.php/Date_and_Time_Functions#FormatDate

mattkhan:
MC format is no of days since 31 Dec 1899 if I remember correctly so the basic process is convert your timestamp to days (eg divide by 86400 if it is in seconds) then add the no of days between MC base date and Unix epoch

zybex:
This works and follows Mattkhan's recipe:
FormatDate(Math(([UnixTime]+7200)/86400+25569),%c)

- [UnixTime] is the timestamp
- 7200 is your timezone offset in seconds - replace with +/- your actual offset.
- 25569 is a constant to adjust to the unix epoch = days from 31/12/1899 to 01/01/1970

In Germany it's now:
FormatDate(Math((1714379553+7200)/86400+25569),%c)     =   29/04/2024 10:32:33

macky88:
Thank you all! Especially zybex for putting all the pieces together.

Navigation

[0] Message Index

Go to full version