2008/09/22 10:23

Convert System.DateTime to UNIX timestamp


In case of development in clinet/server application, datetime formation conversion is frequently required.
Following is the simple example for DateTime Conversion.

private double ConvertToTimestamp(DateTime value)
{
    //create Timespan by subtracting the value provided from
    //the Unix Epoch
    TimeSpan span = (value - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime());

    //return the total seconds (which is a UNIX timestamp)
    return (double)span.TotalSeconds;
}
Trackback 2 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject Order phentermine online uk.

    Tracked from Phentermine online pharmacy. 2010/04/15 19:44 delete

    Buy phentermine online. Online phentermine. Cheapest phentermine online.

  2. Subject Phentermine cheap.

    Tracked from Buy cheap phentermine. 2010/05/03 21:56 delete

    Cheap phentermine. Phentermine cheap. Buy cheap phentermine fre.