Takes a date and creates a new UTC Date component out of the date the original date is representing. - CSharp System

CSharp examples for System:DateTime UTC

Description

Takes a date and creates a new UTC Date component out of the date the original date is representing.

Demo Code


using System;/*  w  w w.  ja  v  a  2  s  . com*/

public class Main{
        /// <summary>
        /// Takes a date and creates a new UTC Date component out of the date the original date is representing.
        /// </summary>
        /// <param name="date">The date.</param>
        /// <returns>A new UTC date representing midnight on the specified date.</returns>
        public static DateTime ToUtcDate(DateTime date)
        {
            return new DateTime(date.Year, date.Month, date.Day, 0, 0, 0, DateTimeKind.Utc);
        }
}

Related Tutorials