Problems converting string to DateTime
First, you need to keep in mind that there are several ways a DateTime / TimeSpan can present itself, you can check this here . So it is not very safe for you to convert a string to DateTime / TimeSpan without proper care as this may suffer interference from the regional settings that the server has, since the default DateTime / TimeSpan format is defined by this.
A secure solution
The TryParseExact method allows you to define one or more formats for TimeSpan and DateTime, as well as ignoring the regional language settings and letting us know if it was successful or not! This all guarantees a much more robust code.
Note: Note that I'm not thinking about setting CultureInfo in Web.Config, I just thought of a code-level solution.
The Code
private static void Main(string[] args)
{
DateTime dataJaConhecida = DateTime.Now.Date;
TimeSpan horasConvertidas;
if (!TimeSpan.TryParseExact("03:12", @"h\:m", CultureInfo.InvariantCulture, out horasConvertidas))
{
Console.WriteLine("Horas no formato inválido");
}
else
{
Console.WriteLine(dataJaConhecida.ToString("dd/MM/yyyy HH:mm"));
dataJaConhecida += horasConvertidas;
Console.WriteLine(dataJaConhecida.ToString("dd/MM/yyyy HH:mm"));
}
Console.ReadKey();
}