You must define the input time format and then call the ToString () method on your vb.net object, entering the same format.
So, for example, if your input format is h: mm: ss tt, it seems, in your case, one of the methods:
Dim compareTime As String = "1:42:21 PM" If compareTime = DateTime.Now.ToString("h:mm:ss tt") Then ' The times match End If
If you want to do some sort of comparison, you should use the DateTime.Parse () function to convert the input date to a DateTime object. Then you can simply use> or <signs:
Dim myCompareTime As DateTime = DateTime.Parse("1:42:21 PM") If myCompareTime.TimeOfDay > DateTime.Now.TimeOfDay Then ' Compare date is in the future! End If
source share