Returns the Start of the given month (the fist millisecond of the given date) - CSharp System

CSharp examples for System:DateTime Second

Description

Returns the Start of the given month (the fist millisecond of the given date)

Demo Code


using System;//from   w w w  . j a  va2 s .  c o  m

public class Main{
        /// <summary>
        /// Returns the Start of the given month (the fist millisecond of the given date)
        /// </summary>
        /// <param name="obj">DateTime Base, from where the calculation will be preformed.</param>
        /// <returns>Returns the Start of the given month (the fist millisecond of the given date)</returns>
        public static DateTime BeginningOfMonth(this DateTime obj)
        {
            return new DateTime(obj.Year, obj.Month, 1, 0, 0, 0, 0);
        }
}

Related Tutorials