C# 时间戳

Unix time 表示自1970年1月1日01T00:00: 00Z (1970:00:00:00:00:,上午 12:00 AM UTC) 的秒数。 它不会考虑闰秒的时间。
此方法首先将当前实例转换为 UTC,然后再返回其 Unix 时间。 对于 1970-01-01T00:00:00Z 之前的日期和时间值,此方法返回一个负值。

C#

string timestamp = DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
// 返回自 1970-01-01T00:00:00.00Z 起已经过的秒数

https://docs.microsoft.com/zh-cn/dotnet/api/system.datetimeoffset.tounixtimemilliseconds?view=net-5.0

扩展

C#

public long ToUnixTimeMilliseconds ();
// 返回自 1970-01-01T00:00:00.000Z 起已经过的毫秒数。
原文地址:https://www.cnblogs.com/microestc/p/15046802.html