This tutorial will show you how to convert datetime to timestamp using C#.Net

By default, The DateTime class haven't got function support convert directly from datetime to timestamp.

To convert a DateTime to TimeStamp you can create a timespan by subtracting the value provided from the Unix Epoch.

/// <summary>
/// Convert a DateTime value to a UNIX Timestamp
/// </summary>
/// <param name="value">date to convert///<returns></returns>
private static double ConvertDateTimeToTimestamp(DateTime value)
    TimeSpan epoch = (value - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()); 
    //return the total seconds (which is a UNIX timestamp)
    return (double)epoch.TotalSeconds;