Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to calculate miliseconds 1

Status
Not open for further replies.

jjangli

Programmer
Mar 29, 2002
4
NL
Hello All,

Is it possible to calculate the number of miliseconds?

I use the DateDiff("s",...) function to calculate the difference is seconds, but now I need the difference in miliseconds.

Anyone got a clue?
Thx, Jeff
 
Sorry, I don't think you can do that with ASP, I use JS to get millisecods:

<script language=jscript runat=server>
function y2k(number) { return (number < 1000) ? number + 1900 :
number; }
function milliDif() {
var d = new Date();
return Date.UTC(y2k(d.getYear()),d.getMonth(),d.getDate(),d.getHours(),
d.getMinutes(),d.getSeconds(), d.getMilliseconds())
}
</script>

<% timeNow = milliDif()
response.write &quot;This page was generated in: &quot; & timeNow-timeThen %> milliseconds.


&quot;Taxes are the fees we pay for civilized society&quot; G.W.
 
Thx!

This means I can finally stop my search on the Internet.
Your Javascript solution will do nicely!
 
Hi,
If you are working in ASP.NET then you can use TimeSpan (which provide the best resolution )like follows:
DateTime moment1 = DateTime.Now;
DateTime moment2 = new DateTime(2003,10,10,19,26,49,300);
TimeSpan ts = moment1 - moment2;
TextBox1.Text = &quot;&quot; + ts.TotalMilliseconds;

GB

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top