Javascript timer using date object only

Discussion in 'Software' started by micro, Jan 31, 2007.

  1. micro

    micro Private E-2

    Hi,

    I want to create the above only using the Date object and its methods, I don't want to use setInterval or any other 'standard' functions. I am not asking anyone to code a solution; just a few pointers. At the moment I am attempting to use the difference between two Date objects using the getSeconds() method. The first object is created and the result passed to a variable; this value is then passed as a parameter to a function call within a Do..While loop: this function terminates when the returned call becomes false. Within the called function a second Date object is instantiated within another Do..Whlie loop and it's result passed to a local variable. I then use an If statement to test if the difference between the two objects is zero(seconds) the loop continues until this is false: hopefully the loop should have (at least) taken one second to do the job and return false to the calling function and hence release the program do the rest of it's job.

    I initially used setInterval to test the rest of the program which works great, but I want to use a more 'basic' approach. There doesn't seem to be easy access to documentation or description on how functions like setInterval work under the hood: I want to really understand how something like this could be replicated by using basic building 'blocks': I realise my approach may be less than optimal but I am a beginner and want to understand.

    Thanks
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds