Function that creates a timestamp in c#

I always use something like the following:

public static String GetTimestamp(this DateTime value)
    return value.ToString("yyyyMMddHHmmssfff");

This will give you a string like 200905211035131468, as the string goes from highest order bits of the timestamp to lowest order simple string sorting in your SQL queries can be used to order by date if you’re sticking values in a database

Leave a Comment