GetTimestamp()

  • Thread starter Thread starter Alan T
  • Start date Start date
A

Alan T

Anyone knows how to convert the ticks into seconds or milliseconds?

beginTick = GetTimestamp();
endTick = GetTimestamp();

totalTick = endTick - beginTick;

How many seconds will be the totalTick ?
 
Alan T said:
Anyone knows how to convert the ticks into seconds or milliseconds?

beginTick = GetTimestamp();
endTick = GetTimestamp();

totalTick = endTick - beginTick;

How many seconds will be the totalTick ?

That depends on your Stopwatch, as the documentation clearly indicates. You
need to look at the Stopwatch.Frequency property to determine how many ticks
there are per second.

IMHO, if what you want is a time with the resolution of seconds or
milliseconds, then it would make more sense to just use the DateTime.Ticks
property. But if you really want to use the Stopwatch class, you can
convert from ticks to seconds simply by dividing the total ticks by the
frequency. Divide that result by 1000 to find milliseconds.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top