Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 10-17-2006, 10:00 PM Javascript Needed...
Banned

Posts: 61
Name: Oh, don't go there
Location: United States
Trades: 0
Hi,

Does anyone have a clock script that will count up? Meaning, say I have a line of text that says:

I have been out of work for -- days so far

how can I get a javascript that automatically fills the -- above with a number based on a 24 a day period. It needs to keep going up for each day. So after 24 hours the above line says 1 day instead of -- days and 48 hours would be 2 days instead of -- etc..etc..

Thanks.

Last edited by Frostydasnowman; 10-17-2006 at 10:02 PM..
Frostydasnowman is offline
Reply With Quote
View Public Profile Visit Frostydasnowman's homepage!
 
 
Register now for full access!
Old 10-19-2006, 02:53 AM Re: Javascript Needed...
seomumbai's Avatar
Skilled Talker

Posts: 98
Trades: 0
I think this cannot be done in client script you can do it only in Server Side.
seomumbai is offline
Reply With Quote
View Public Profile
 
Old 10-19-2006, 03:17 AM Re: Javascript Needed...
Banned

Posts: 61
Name: Oh, don't go there
Location: United States
Trades: 0
Don't believe you, I worked with both javascript and php before, but I just cannot think writting code atm, it's highly impossible when I work 14+ hours a day doing 'outside' work...

Thanks anyway!
Frostydasnowman is offline
Reply With Quote
View Public Profile Visit Frostydasnowman's homepage!
 
Old 10-21-2006, 05:55 AM Re: Javascript Needed...
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by seomumbai
I think this cannot be done in client script you can do it only in Server Side.
Of course it can be done

Code:
//Set the start date
var startDate =new Date(2006, 9, 21) // (yyyy, m , d) Month is 0-11 in JavaScript
today=new Date()
//Convert 24 hours into milliseconds
var oneDay=1000*60*60*24
//Calculate the difference between today and the start and convert to days
var numDays = Math.ceil((today.getTime()-startDate.getTime())/(oneDay))
if (numDays != 1) {
	daysText = " days have ";
	} else {
	daysText = " day has ";
}


document.write(numDays + daysText + "elapsed since the start"
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Javascript Needed...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.40127 seconds with 12 queries