How to add a 12 hour string to datetime

434 Views Asked by At

I have a datetime object with the date in it, but no time.

I have a string that has the 12 hours (ex. "6:00 AM", "10:00 AM", "4:00 PM", "11:00 PM") How can I add this time to the date time variable?

1

There are 1 best solutions below

0
On BEST ANSWER

Try this

var datetime = DateTime.Now;        
var newDateTime = datetime.AddHours(DateTime.Parse("6:00 PM").Hour);