Floor DateTime - CSharp System

CSharp examples for System:DateTime Calculate

Description

Floor DateTime

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from w w w  . j av  a 2s .  c  om*/

public class Main{
        public static DateTime Floor(this DateTime date, TimeSpan span)
        {
            long ticks = (date.Ticks / span.Ticks);
            return new DateTime(ticks * span.Ticks, date.Kind);
        }
}

Related Tutorials