Reputation: 2101
I'm trying to create a 13 character timestamp within my application but after searching online I am at a loss.
Are these 13 character timestamps special types of timestamps? And how can one generate them?
Here is an example timestamp: 1330650156663
Upvotes: 4
Views: 10552
Reputation: 21086
DateTime.Now.Ticks.ToString()
You probably want something like that, though you'd have to use a string operation to get it to 13 characters if it isn't already.
Upvotes: 0
Reputation: 13755
You need milliseconds (instead of just second)
TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
long timestamp = (long ) t.TotalMilliseconds;
Console.WriteLine (timestamp);
Upvotes: 1
Reputation: 8408
It's the number of milliseconds since 1/1/1970 00:00 (unix epoche)
long timestamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds;
Console.WriteLine(timestamp);
Upvotes: 4
Reputation: 881133
Thirteen-character timestamps are generally UNIX timestamps with a millisecond precision.
For example, 1330650156 (without the 663 milliseconds at the end) is 02 Mar 2012 01:02:36 UTC
(see http://www.epochconverter.com/).
Upvotes: 1