There he is:
var ts = new TimeSpan(23, 47, 00); ts = TimeSpan.FromMinutes(5 * Math.Ceiling(ts.TotalMinutes / 5));
Or with a grain of sugar:
public static class TimeSpanExtensions { public static TimeSpan RoundTo(this TimeSpan timeSpan, int n) { return TimeSpan.FromMinutes(n * Math.Ceiling(timeSpan.TotalMinutes / n)); } } ts = ts.RoundTo(5);
source share