13 Character Timestamp

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

5

4 Answers

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); 

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 ).

You need milliseconds (instead of just second)

 TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); long timestamp = (long ) t.TotalMilliseconds; Console.WriteLine (timestamp); 
1
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.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like