我正在使用这个:
var a = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds.ToString()
但这给了我
1546582625.5838
在没有.5838的情况下,如何将其四舍五入到秒数?
答案 0 :(得分:2)
连续或圆形截断
var a = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))
.TotalSeconds;
var b = Math.Round(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))
.TotalSeconds);
var c = Math.Truncate(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))
.TotalSeconds);