DateTimeOffset.Second Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan komponen kedua dari waktu jam yang diwakili oleh objek saat ini DateTimeOffset .
public:
property int Second { int get(); };
public int Second { get; }
member this.Second : int
Public ReadOnly Property Second As Integer
Nilai Properti
Komponen kedua objek DateTimeOffset , dinyatakan sebagai nilai bilangan bulat antara 0 dan 59.
Contoh
Contoh berikut menampilkan komponen kedua objek DateTimeOffset dengan tiga cara berbeda:
Dengan mengambil nilai properti Second.
Dengan memanggil ToString(String) metode dengan penentu format "s".
Dengan memanggil ToString(String) metode dengan penentu format "ss".
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.
Keterangan
Properti Second tidak dipengaruhi oleh nilai Offset properti .
Anda juga dapat membuat representasi string dari DateTimeOffset komponen kedua objek dengan memanggil ToString metode dengan penentu format kustom "s", atau "ss".