There is a ToUnixTimeMilliseconds for DateTimeOffset in System
You can write similar method for DateTime:
public static long ToUnixTimeSeconds(this DateTime value)
{
return value.Ticks / 10000000L - 62135596800L;
}
10000000L - converting ticks to seconds
62135596800L - converting 01.01.01 to 01.01.1978
There is no problem with Utc and leaks