How to

add TimeSpan to DateTime

Published: 24. October 2011 | Updated: 26. October 2011
License: Microsoft Public License (MS-PL)
Categories: Framework » DateTime & TimeSpan
Tags: C# DateTime Math
Was this snippet helpful for you? YESYES / NONO
DateTime dateTime = new DateTime(2011, 1, 20, 16, 40, 55, 500, DateTimeKind.Utc);
TimeSpan timeSpan = new TimeSpan(5, 10, 20, 0);

DateTime result = dateTime.Add(timeSpan);

Console.WriteLine(result);
Console Output:
2011-01-26 3:00:55 AM
Send us feedback about this snippet »



Related Snippets: