CSharp examples for System:DateTime Minute
To Nearest Minute
using System;//from ww w . j a v a 2 s . c om public class Main{ public static DateTime ToNearestMinute(this DateTime dateTime) { return dateTime.Truncate(TimeSpan.FromMinutes(1)); } private static DateTime Truncate(this DateTime dateTime, TimeSpan timeSpan) { if (timeSpan == TimeSpan.Zero) { return dateTime; } return dateTime.AddTicks(-(dateTime.Ticks%timeSpan.Ticks)); } }