Question: I have a time string as `12:48 AM`. I want to convert this string into `TimeSpan` to append with `DateTime` Object. Currently I am trying the following snippets. 

```
string format = "dd/MM/yyyy";
CultureInfo provider = CultureInfo.InvariantCulture;
var date = DateTime.ParseExact(dateValue, format, provider);

string timeFormate = "H:mm AM";
string timeValue = "12:48 AM";
var time = TimeSpan.ParseExact(timeValue,timeFormate,provider);
DateTime launchDate = date + time;

```

I am getting 

> 
> *Input string was not in a correct format*
> 
> 
> 

exception at line 

```
 var time = TimeSpan.ParseExact(timeValue,timeFormate,provider);

```

Please suggest me how to convert my specified string into time.

Answer: 
You can parse it to `DateTime` and use it's [`TimeOfDay` property](http://msdn.microsoft.com/en-us/library/system.datetime.timeofday(v=vs.110).aspx) to get the time:

```
DateTime time = DateTime.ParseExact("12:48 AM", "h:mm tt", CultureInfo.InvariantCulture);
DateTime launchDate = date + time.TimeOfDay;

```

Note that i've also changed the format string since you need `tt` for the AM/PM designator.
`12:48 AM` is not a [`TimeSpan`](http://msdn.microsoft.com/en-us/library/System.TimeSpan%28v=vs.110%29.aspx), it is a time part of a [`DateTime`](http://msdn.microsoft.com/en-us/library/System.DateTime%28v=vs.110%29.aspx). You need to parse it to `DateTime`, not `TimeSpan`.

You can use to add [`.TimeOfDay` property](http://msdn.microsoft.com/en-us/library/system.datetime.timeofday%28v=vs.110%29.aspx) of your time and add it to `date`. This property returns only time part of your `DateTime` as a `TimeSpan`.

```
string timeValue = "12:48 AM";
var time = DateTime.ParseExact(timeValue, "h:mm tt", CultureInfo.InvariantCulture);
DateTime launchDate = date + time.TimeOfDay;

```