Android Question Comparing the system time as a string

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

I would like to use an If statement like this:

B4X:
If SystemTime = "13:00" then
    ' Coding goes here.
End If

Can you show me the coding needed to do this?

Thanks.
 

LucaMs

Expert
Licensed User
Longtime User
B4X:
Dim ph As Phone

Dim Time12_24 As String = ph.GetSettings("time_12_24")

Dim SystemTime As String
DateTime.TimeFormat = "hh:mm"
SystemTime = DateTime.Time(DateTime.Now)
Log(SystemTime)

If Time12_24 = "24" Then
    If SystemTime = "13:00" then
        ' Coding goes here.
    End If
Else
    If SystemTime = "01:00"
        ' Coding goes here.
    End If
End If
 
Last edited:
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Thanks for the code and help. I will use your coding. :)



B4X:
Dim ph As Phone

Dim Time12_24 As String = ph.GetSettings("time_12_24")

Dim SystemTime As String
DateTime.TimeFormat = "hh:mm"
SystemTime = DateTime.Time(DateTime.Now)
Log(SystemTime)

If Time12_24 = "24" Then
    If SystemTime = "13:00" then
        ' Coding goes here.
    End If
Else
    If SystemTime = "01:00"
        ' Coding goes here.
    End If
End If
 
Upvote 0
Top