Javascript Timer

This is a discussion on "Javascript Timer" within the JavaScript Forum section. This forum, and the thread "Javascript Timer are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 1st, 2007, 15:02
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,619
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
Javascript Timer

I just thought I'd share this little snippet I put together last night...

A (very) simple JavaScript timer object. I use it to help me measure how long scripts take to execute...

timer.start(); // starts counting
timer.since(); // returns elapsed time in milliseconds

The code:
Code: Select all
var timer = {
  time: 0,
  now: function(){ return (new Date()).getTime(); },
  start: function(){ this.time = this.now(); },
  since: function(){ return this.now()-this.time; }
}
As posted on my new blog: Javascript Timer.
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Reply With Quote

Reply

Tags
blog, javascript, jquery, stopwatch, timer

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Timer won't work gleb JavaScript Forum 1 Sep 12th, 2007 08:43
1st timer hosting questions jimbaines Hosting & Domains 16 Jun 21st, 2007 11:27
1st Timer Here, Back in the game allrightythen Introduce Yourself 7 Jun 19th, 2007 01:17
request for help in countdown timer thebmwz4 Classic ASP 4 Sep 4th, 2005 14:45
Self Updating Timer. Amin PHP Forum 4 Jun 24th, 2005 18:37


All times are GMT. The time now is 22:40.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43