Converting a Unix Time Stamp To Date

potman100

Active Member
Licensed User
Longtime User
Hi

Can anybody shed any light on how I would do this in b4a.

I have a timestamp (Seconds since 1/1/70) and I want to
convert it to date & time i.e

The Timestamp

1339830670

converts to

16/06/2012 07:11:10

and then find the difference in hours from the date and time now.

Thanks in advance for any help.

Regards

Potman
 

corwin42

Expert
Licensed User
Longtime User
To convert from a normal unix timestamp to B4A Ticks value you just have to multiply it with 1000. So to get the difference in hours to the current time you can write something like this:

B4X:
TicksDiff = DateTime.Now - unixtimestamp * 1000
HoursDiff = TicksDiff / DateTime.TicksPerHour
 
Upvote 0
Top