I’m attempting to print a timestamp to string, where :
Each timestamp is based on 1970.1.1 and incremented by a (long)amount of seconds and a (long) amount of microseconds(always less then 1s total).
Here’s what I’m doing :
DateTime TimeStamp = new DateTime(1970, 1, 1);
TimeSpan span = new TimeSpan(0, 0, 0, (int)Soc, (int)Fracsec.Fracsec);
TimeStamp += span;
I’ve just noticed that DateTime and TimeSpan use milliseconds instead of microseconds and it is imperative for me that I use microseconds, can anyone tell me how to achieve that?
What I’m trying to do next is to display the result in one operation (hopefully). Any way to do that as well?
Use the
Ticksproperty to achieve microsecond fidelity andDateTime.Format()to display it. See this question for more details. 10Ticksis equal to 1 microsecond.There is also a StopWatch class that provides for more accurate measurement of elapsed time.