Android Question Convert unix time to format HHmm

Peter Simpson

Expert
Licensed User
Longtime User
Linux Time Stamp?

Hello all, I have no idea why I typed Unix in the title, sorry...

I've tried date utils and I've also tried the following,
B4X:
Dim xxx As String = DateTime.Time(1395772166) * 1000
but I just can't get the correct 2 times once after another.

Basically I know that the following is correct:
A. 1395726989 = Tue, 25 Mar 2014 05:56:29
But I keep getting 01/17/1970 04:42:06, even the time is incorrect

I also know that this is correct:
B. 1395772166 = Tue, 25 Mar 2014 18:29:26
But I keep getting 01/17/1970 04:42:52, once again the time is incorrect.

Can somebody please shine a light on this for me :mad:

I just need to convert 1395726989 and 1395772166 to read HHmm format.

Thank you
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
B4X:
Dim unixtime As Long = 1395744770 ' 25.03.2014 10:52:50
Dim targetDate As Long = DateUtils.UnixTimeToTicks(unixtime)
DateTime.DateFormat = "dd.MM.yyyy"
DateTime.TimeFormat = "HH:mm:ss"
DateTime.SetTimeZone(0)
Log (DateTime.Date(targetDate))   '25.03.2014
Log (DateTime.Time(targetDate))   '10:52:50
 
Upvote 0
Top