Mega Code Archive

 
Categories / C# / Date Time
 

Gets current date and time with the local times offset from Coordinated Universal Time (UTC)

using System; using System.Globalization; public class Test {    public static void Main()    {           DateTimeOffset dto;         dto = DateTimeOffset.Now;         Console.WriteLine(dto.ToString("M/d/yyyy h:mm:ss"));         Console.WriteLine(dto.ToString("zzz"));    } } /* 2/25/2011 7:18:09 -08:00 */