I have string which contains a time (obtained from a DB):
string user_time = "17:10:03"; //Hours:minutes:seconds
DateTime time_now = DateTime.Now;
How do I compare this string to a DateTime? I’d like something like this:
if(time_now > user_time)
{
//Do something
}
else
{
//Do something
}
DateTime supports comparison, but first you need to parse the date-time string, DateTime.Parse() should suffice:
Bear in mind, that comparing dates/times sometimes requires awareness of time-zones to make the comparison meaningful.