Round To Minutes - CSharp System

CSharp examples for System:DateTime Minute

Description

Round To Minutes

Demo Code


using System.Globalization;
using System.Collections.Generic;
using System;/*  ww  w  .  j  a  v a2 s  . co  m*/

public class Main{
        [Obsolete("Use RoundToMinute(DateTime, int)")]
        public static DateTime RoundToMinutes(DateTime dateTime, int minInterval)
        {
            var min = dateTime.Minute / minInterval * minInterval;
            return new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, min, 0, dateTime.Kind);
        }
}

Related Tutorials