Converts the specified into UTC time. The actual date and time will remain unchanged. - CSharp System

CSharp examples for System:DateTime UTC

Description

Converts the specified into UTC time. The actual date and time will remain unchanged.

Demo Code


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

public class Main{
        /// <summary>
		/// Converts the specified <see cref="DateTime"/> into UTC time. The actual date and time will remain unchanged.
		/// </summary>
		/// <param name="dateTime">A <see cref="DateTime"/>.</param>
		/// <returns><paramref name="dateTime"/> as UTC time.</returns>
		public static DateTime AsUtc(this DateTime dateTime)
		{
			return DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
		}
}

Related Tutorials