どうも、ちょげ(@chogetarou)です。
DateTimeの秒を取得する方法を紹介します。
方法

DateTimeの秒を取得するには、Secondを使います。
具体的には、DateTimeのSecondにアクセスします。
int seconds = date.Second;
Secondプロパティは、DateTimeの秒を返します。
使用例
using System;
public class Example
{
public static void Main()
{
DateTime currentDay = DateTime.Now;
int seconds = currentDay.Second;
Console.WriteLine(currentDay);
Console.WriteLine(seconds);
}
}
/*
出力:
7/2/2022 7:12:15 AM
15
*/
コメント