How to

combine date and time

Published: 27. October 2011 | Updated: 27. October 2011
License: Microsoft Public License (MS-PL)
Categories: Framework » DateTime & TimeSpan
Tags: C# DateTime
Was this snippet helpful for you? YESYES / NONO
DateTime dateTime = new DateTime(2011, 10, 20, 5, 16, 25);
TimeSpan timeSpan = new TimeSpan(15, 25, 40);

DateTime combined = dateTime.Date + timeSpan;

Console.WriteLine(combined);
Console Output:
2011-10-20 3:25:40 PM
Send us feedback about this snippet »



Related Snippets: