c# convert datetime to timespan code example
Example 1: c# datetime to timestamp
DateTimeOffset.UtcNow.ToUnixTimeSeconds()
Example 2: c# convert datetime to timespan
Add .TimeofDay to the datetime value to make it of type TimeSpan
DateTime.TimeOfDay