Gets a DateTime representing midnight on the current date - CSharp System

CSharp examples for System:DateTime Calculate

Description

Gets a DateTime representing midnight on the current date

Demo Code


using System;/*from   w w w.j a v  a  2s  .c o m*/

public class Main{
        /// <summary>
      /// Gets a DateTime representing midnight on the current date
      /// </summary>
      /// <param name="current">The current date</param>
      public static DateTime Midnight(this DateTime current)
      {
         var midnight = new DateTime(current.Year, current.Month, current.Day);
         return midnight;
      }
}

Related Tutorials