| | |
time calculations
Please support our JavaScript / DHTML / AJAX advertiser: 50% Off 6 Months Web Hosting from 1&1. The World's #1 Host!
![]() |
Take a look at the functions provided by the Date object of Javascript and try your own hand at it. Post your attempt with the problems you are facing if you are stuck.
I don't accept change; I don't deserve to live.
Sacrifice is a painful, pure and beautiful thing.
Dammit, Jones, What the Hell Are Knoll Pointers?!
Sacrifice is a painful, pure and beautiful thing.
Dammit, Jones, What the Hell Are Knoll Pointers?!
It depends a lot on the format in which the times are expressed. Post some code so that we have something to chew on.
I don't accept change; I don't deserve to live.
Sacrifice is a painful, pure and beautiful thing.
Dammit, Jones, What the Hell Are Knoll Pointers?!
Sacrifice is a painful, pure and beautiful thing.
Dammit, Jones, What the Hell Are Knoll Pointers?!
Several questions:
1. What format are the variables "etime" and "stime" in?
2. What do you want the value "2" to represent? It's not seconds or days. It is supposed to be milliseconds, but some implementations use jiffies instead (multiples of the Intel 55 ms interrupt period).
3. What units did you expect "total" to be in? You don't have any guarantee of what unit of measure the variable "total" is in. It is an internal time unit that depends on the computer used.
4. Do you really want to measure 2 ms times? Windows computers can't measure such times without special hardware.
Note that the system clock does not update each millisecond. Usually the system clock is updated once every 55ms jiffy. If you are really trying to measure intervals of 2 ms, you are doomed to failure. I/O itself happens only once every 55 ms on Windows computers.
DOS computers could do this. Windows computers can't.
One thing you could do is make a standard for comparison:
1. What format are the variables "etime" and "stime" in?
2. What do you want the value "2" to represent? It's not seconds or days. It is supposed to be milliseconds, but some implementations use jiffies instead (multiples of the Intel 55 ms interrupt period).
3. What units did you expect "total" to be in? You don't have any guarantee of what unit of measure the variable "total" is in. It is an internal time unit that depends on the computer used.
4. Do you really want to measure 2 ms times? Windows computers can't measure such times without special hardware.
Note that the system clock does not update each millisecond. Usually the system clock is updated once every 55ms jiffy. If you are really trying to measure intervals of 2 ms, you are doomed to failure. I/O itself happens only once every 55 ms on Windows computers.
DOS computers could do this. Windows computers can't.
One thing you could do is make a standard for comparison:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
std = knownEndTime - knownStartTime; // set a standard time interval for your comparison. diffo = end - start; if (diffo > std) { // code for diffo is greater than the standard interval } else { // code for diffo is less than or equal to the standard interval }
Last edited by MidiMagic; Oct 7th, 2007 at 1:24 am.
Daylight-saving time uses more gasoline
![]() |
Similar Threads
- Concerning C++ calculations using printf (C)
- How to use admin passwords with "C" (C)
- Program needs to have time updated every minute (Java)
- Need help with calculations (C++)
- Noob Help needed for Time problem (C++)
- Need help with CPU scheduling algorithms (C++)
- Simple Time/Date Program (C)
- how to find out the time of cpu? (Motherboards, CPUs and RAM)
- Any better way of implementing this recusively? (C++)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: extract links from page to new window
- Next Thread: How do I calculate time interval between to dates in js
Views: 2094 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxcode ajaxexample ajaxhelp animate array asp.net attributes auto autocomplete box bug button cart content cookies count css db design display div dom dynamic element error explorer external fade file firefox flash focus font form function game getselection google hide html ie8 iframe image internet internet-explorer java javascript javascripts jawascriptruntimeerror jquery js login maps match matrixcaptcha media menu modal mysql objects onclick onmouseover parameters paypal php player position post problem programming prototype rated realtimeprojects redirect reload repaeat resize safari script scroll search select show simple size sources sqlite star stars string table text toggle uncaught upload variables web window xml






