// 获取本地时间 DateTime currentTime = DateTime.Now; // 将时间格式化为字符串 string timeString = currentTime.ToString('yyyy/MM/dd HH:mm:ss');

// 在控制台输出本地时间 Debug.Log('Local Time: ' + timeString + '\r\n1号配电变压器保护\r\n1号配电变压器零序过流\r\n2号配电变压器过流2段');

// 添加2秒 DateTime futureTime2 = currentTime.AddSeconds(2);

// 输出本地时间20秒后的时间 Debug.Log('Future Local Time: ' + futureTime2.ToString('yyyy/MM/dd HH:mm:ss') + ' 445自投');

// 添加20秒 DateTime futureTime = currentTime.AddSeconds(20);

// 输出本地时间20秒后的时间 Debug.Log('Future Local Time: ' + futureTime.ToString('yyyy/MM/dd HH:mm:ss') + '2号配电变压器过负荷报警');

C# 获取当前时间并添加秒数示例代码

原文地址: https://www.cveoy.top/t/topic/qmhQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录