Have datetime.now return to the nearest second

前端 未结 6 726
眼角桃花
眼角桃花 2021-01-04 04:38

I have a \"requirement\" to give a timestamp to the nearest second... but NOT more accurate than that. Rounding or truncating the time is fine.

I have come up with t

6条回答
  •  一生所求
    2021-01-04 05:05

    Try this

    TimeSpan span= dateTime.Subtract(new DateTime(1970,1,1,0,0,0, DateTimeKind.Utc));
    return span.TotalSeconds;
    

提交回复
热议问题