Mega Code Archive

 
Categories / C# / Date Time
 

Gets second from DateTimeOffset

using System; using System.Globalization; public class Test {    public static void Main()    {           DateTimeOffset theTime = new DateTimeOffset(2008, 6, 12, 21, 16, 32, DateTimeOffset.Now.Offset);                  Console.WriteLine("The second component of {0} is {1}.",theTime, theTime.ToString("ss"));    } }         //The second component of 6/12/2008 9:16:32 PM -08:00 is 32.