Page 1 of 1

Convert Unix Timestamp

Posted: Tue Aug 16, 2022 7:50 am
by bluesfannoz
Anyone know a way in BR to convert a Unix Timestamp to work with BR?

Example of a Unix Timestamp 1660657729

Equivalent Date Time:
August 16, 2022 8:48:49 AM

Re: Convert Unix Timestamp

Posted: Tue Aug 16, 2022 8:28 am
by GomezL
See: https://www.unixtimestamp.com/
Seconds Since Jan 1/1970

Also, TIMER is BR is the same value:


Human Readable Time Seconds
1 Hour 3600 Seconds
1 Day 86400 Seconds
1 Week 604800 Seconds
1 Month (30.44 days) 2629743 Seconds
1 Year (365.24 days) 31556926 Seconds

I didn't do the math, but you should be able to compare the value to Timer (NOW) and then do date math.

Re: Convert Unix Timestamp

Posted: Tue Aug 16, 2022 8:32 am
by GomezL
David provided the magic formula!

pr date$(days(19700101)+timer/86400,'M/D/CY') = 8/16/2022

Re: Convert Unix Timestamp

Posted: Tue Aug 16, 2022 8:40 am
by bluesfannoz
Thanks! David and Luis Exactly what I needed!

Re: Convert Unix Timestamp

Posted: Tue Aug 16, 2022 8:50 am
by bluesfannoz
In actuality Luis, Timer is what I needed because I am trying to determine how long ago I authorized a user and the api returns a unix timestamp. So I can just subtract that timestamp from Timer and know how many seconds it has been! Perfect!

Thanks again both David for your correct calculation and Luis for pointing out the Timer function!