How to get correct timestamp in C#

I would like to get valid timestamp in my application so I wrote:

public static String GetTimestamp(DateTime value)
{
    return value.ToString("yyyyMMddHHmmssffff");
}
//  ...later on in the code
String timeStamp = GetTimestamp(new DateTime());
Console.WriteLine(timeStamp);

output:

000101010000000000

I wanted something like:

20140112180244

What have I done wrong?

6 Answers
6

Leave a Comment