convert date time to timespant C# 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