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

CSharp examples for System:DateTime Local

Description

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

Demo Code


using System.Diagnostics;
using System;/*from w w w .  j  ava 2  s. co  m*/

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

Related Tutorials