Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i get from Stopwatch.GetTimestamp() to a DateTime?

Duplicate of: How to get timestamp of tick precision in .NET / C#?
How do i get from Stopwatch.GetTimestamp() to a DateTime

Assume Stopwatch.IsHighResolution is true

like image 218
Simon Avatar asked Sep 17 '09 12:09

Simon


1 Answers

If it's a high resolution counter, there's no guarantee that the value has any correlation with the real time - for example, it may well be "ticks since the computer booted." For a non-high resolution timer, you could use new DateTime(Stopwatch.GetTimestamp()) but that won't necessarily give a useful value for a high resolution timer. (It certainly doesn't on my box.)

What are you trying to use this for? The idea of Stopwatch is to measure intervals of time.

like image 172
Jon Skeet Avatar answered Oct 22 '22 04:10

Jon Skeet