DateTimeOffset.Second 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取由当前 DateTimeOffset 对象所表示的时钟时间的秒组成部分。
public:
property int Second { int get(); };
public int Second { get; }
member this.Second : int
Public ReadOnly Property Second As Integer
属性值
DateTimeOffset 对象的秒组成部分,以 0 到 59 之间的一个整数值来表示。
示例
以下示例以三种不同的方式显示对象的第二个 DateTimeOffset 组件:
通过检索属性的值 Second 。
通过使用“s”格式说明符调用 ToString(String) 方法。
通过使用“ss”格式说明符调用 ToString(String) 方法。
DateTimeOffset theTime = new DateTimeOffset(2008, 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 example produces the following output:
// The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
// The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
// The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
let theTime = DateTimeOffset(2008, 6, 12, 21, 16, 32, DateTimeOffset.Now.Offset)
printfn $"The second component of {theTime} is {theTime.Second}."
printfn $"""The second component of {theTime} is{theTime.ToString " s"}."""
printfn $"The second component of {theTime} is {theTime:ss}."
// The example produces the following output:
// The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
// The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
// The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
Dim theTime As New DateTimeOffset(#6/12/2008 9:16:32PM#, _
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 example produces the following output:
' The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
' The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
' The second component of 6/12/2008 9:16:32 PM -07:00 is 32.
注解
该 Second 属性不受该属性的值 Offset 的影响。
还可以通过使用“s”或“ss”自定义格式说明符调用ToString方法来创建对象的第二个DateTimeOffset组件的字符串表示形式。