C# DateTimeOffset Second

Description

DateTimeOffset Second gets the second component of the clock time represented by the current DateTimeOffset object.

Syntax

DateTimeOffset.Second has the following syntax.


public int Second { get; }

Example

The following example displays the second component of a DateTimeOffset object in three different ways:


using System;/*from  w  w  w. ja va  2  s  . c  om*/

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 »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version