Hi there,
I have a Seekbar in my app that goes from 0 to 7200 (2 hours).
Now I want to display a label that appears that selected value in HH:MM:SS
I have tried many examples and read the entire forum about it and it doesn't work.
The only thing I could make work are the seconds, which I used "Value Mod 60".
But how about Minutes and Hours?
Dim sVal, hrs, mins As Int
sVal = seekbar1.Valu
hrs = Floor(sVal / 60)
mins = sVal Mod 60
If hrs = 1 Then
Log (hrs & " hr : " & mins & " mins")
Else
Log (hrs & " hrs : " & mins & " mins")
End If
It will display the seconds if you feed it from the seek bar, the Step 60 in the code just sends each minute. Which is why it isn't displaying seconds. I just didn't want to log 7200 entries. You can do:
B4X:
DateTime.SetTimeZone(0)
For i = 0 To 7200
Log(DateTime.Time(i*1000))
Next
It will display the seconds if you feed it from the seek bar, the Step 60 in the code just sends each minute. Which is why it isn't displaying seconds. I just didn't want to log 7200 entries. You can do:
B4X:
DateTime.SetTimeZone(0)
For i = 0 To 7200
Log(DateTime.Time(i*1000))
Next
You only need to set the time zone once, probably in Activity_Create, unless you are using the clock for anything else like displaying time then you can record the initial setting with DateTime.TimeZoneOffset, and set it back when you need to