INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Function to translate Unix timestamp to Date?  (Read 33 times)

macky88

  • Member
  • *
  • Posts: 1
Function to translate Unix timestamp to Date?
« on: Yesterday at 09:10:51 pm »

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!
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8939
Re: Function to translate Unix timestamp to Date?
« Reply #1 on: Yesterday at 10:28:13 pm »

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3960
Re: Function to translate Unix timestamp to Date?
« Reply #2 on: Today at 02:23:36 am »

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
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2365
Re: Function to translate Unix timestamp to Date?
« Reply #3 on: Today at 03:34:37 am »

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
Logged
Pages: [1]   Go Up