Returns the FIRST possible time unit for provided Hour in dateTime - CSharp System

CSharp examples for System:DateTime Hour

Description

Returns the FIRST possible time unit for provided Hour in dateTime

Demo Code


using System.Globalization;
using System;/*from   w  ww .  j  a va 2 s  .com*/

public class Main{
        #endregion

        #region Start of Hour/Day/Week/Month/Year

        /// <summary>
        /// Returns the FIRST possible time unit for provided Hour in dateTime
        /// </summary>
        public static DateTime StartOfHour(this DateTime dateTime)
        {
            return new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, 0, 0);
        }
}

Related Tutorials