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 561 times)

macky88

  • Member
  • *
  • Posts: 2
Function to translate Unix timestamp to Date?
« on: April 28, 2024, 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: 9139
Re: Function to translate Unix timestamp to Date?
« Reply #1 on: April 28, 2024, 10:28:13 pm »

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4226
Re: Function to translate Unix timestamp to Date?
« Reply #2 on: April 29, 2024, 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: 2616
Re: Function to translate Unix timestamp to Date?
« Reply #3 on: April 29, 2024, 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

macky88

  • Member
  • *
  • Posts: 2
Re: Function to translate Unix timestamp to Date?
« Reply #4 on: April 30, 2024, 12:31:19 am »

Thank you all! Especially zybex for putting all the pieces together.
Logged
Pages: [1]   Go Up