Get the second component of the clock time represented by the current DateTimeOffset in CSharp

Description

The following code shows how to get the second component of the clock time represented by the current DateTimeOffset.

Example


using System;//ww w.java 2s  . co  m

public class MainClass{
  public static void Main(String[] argv){  
    DateTimeOffset theTime = new DateTimeOffset(2014, 6, 12, 21, 16, 32, 
                                 DateTimeOffset.Now.Offset);
    Console.WriteLine("The second component of {0} is {1}.", 
                      theTime, theTime.Second);
    
    Console.WriteLine("The second component of {0} is{1}.", 
                      theTime, theTime.ToString(" s"));
    
    Console.WriteLine("The second component of {0} is {1}.", 
                      theTime, theTime.ToString("ss"));
    

  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var