How I can convert string 23:59 to datetime format? So that I can reduce the current time in it.
Example: String = 23:59 minus Datime.Now = 13.8.2014 10:59:55
Time left 12 hours 0 minutes.
How I can convert string 23:59 to datetime format? So that I can reduce the current time in it.
Example: String = 23:59 minus Datime.Now = 13.8.2014 10:59:55
Time left 12 hours 0 minutes.
use this :
DateTime date = Convert.ToDateTime(string);
System.TimeSpan diff= DateTime.Now.Subtract(date);
diff will contain your deffernce
i would use ParseExact
TimeSpan tsDifference = DateTime.ParseExact("23:59", "HH:mm", System.Globalization.CultureInfo.InvariantCulture) - DateTime.Now;