PDA

View Full Version : Looking for a count up script



darmie_a_Phoenix
10-14-2004, 05:47 PM
Hello,

I am hoping someone here can help me. I am looking for a count up script to put on my goddaughter’s web site. I have found a count up script at http://www.dynamicdrive.com/dynamicindex6/countingup.htm . However, this script show only shows d,h,m,s. I would like to find something to show y,m,d,h,m can any one help me with this.

cr3ative
10-14-2004, 06:39 PM
I'll modify the script for you and post it when completed

*gets calculator out*

cr3ative

cr3ative
10-14-2004, 07:02 PM
YMHMS script i'm afraid. I just couldn't get days to work, because of this:

To get years we divide days by 365
To get months we divide years by 12 and take off the amount of months already stated for in the years, easy enough
But to get days in this context, we need to take the months and years already stated in the previous two... and its too late at night for me to handle this! (edit: by the way, I'm in GMT. It's not really 8:00 PM.)

Still, here's the YMHMS script.



<script language="JavaScript1.2">

//Dynamic countup Script- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com

function setcountup(theyear,themonth,theday){
yr=theyear;mo=themonth;da=theday
}

//////////CONFIGURE THE countup SCRIPT HERE//////////////////

//STEP 1: Configure the date to count up from, in the format year, month, day:
//This date should be less than today
setcountup(1999,3,2)

//STEP 2: Configure text to be attached to count up
var displaymessage="have passed since the debut of our site!"

//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countup area
var countupwidth='95%'
var countupheight='20px' //applicable only in NS4
var countupbgcolor='lightyellow'
var opentags='<font face="Verdana"><small>'
var closetags='</small></font>'

//////////DO NOT EDIT PASS THIS LINE//////////////////

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''

function start_countup(){
if (document.layers)
document.countupnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countupie") : countupie
countup()
}

if (document.all||document.getElementById)
document.write('<span id="countupie" style="width:'+countupwidth+'; background-color:'+countupbgcolor+'"></span>')

window.onload=start_countup


function countup(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
paststring=montharray[mo-1]+" "+da+", "+yr
dd=Date.parse(todaystring)-Date.parse(paststring)
dyear=Math.floor(dd/(60*60*1000*24*365)*1)
dmonth=Math.floor(dd/(60*60*1000*24*12)/(dyear*12))
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)

if (document.layers){
document.countupnsmain.document.countupnssub.document.write(opentags+dyear+" years, "+dmonth+" months, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+displaymessage+closetags)
document.countupnsmain.document.countupnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+dyear+" years, "+dmonth+" months, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+displaymessage+closetags

setTimeout("countup()",1000)
}
</script>

<ilayer id="countupnsmain" width=&{countupwidth}; height=&{countupheight}; bgColor=&{countupbgcolor}; visibility=hide><layer id="countupnssub" width=&{countupwidth}; height=&{countupheight}; left=0 top=0></layer></ilayer>


If you'll excuse me, I have to collapse now. :)

cr3ative

burnfactor
02-08-2005, 11:59 PM
anyone willing to update this to include days for me? :D

Also, I'd love it if in the countup, it didn't just count up from a specific day, but a TIME, too.

I want to count up from 11:40 PM EST on 10/27/04. Just 10/27/04 isn't going to cut it for me! ;)

momofHayes
02-11-2005, 04:49 PM
I'm trying to put the counter up on my sons site for the year, months, and days since he passed. I used your directions above but I don't know how to get the days. I have the counter on his page at www.hayeskent.com/resting/restingplace.html

tippi
06-15-2005, 11:53 AM
Hi there. I'm also looking for a countup script that will count from a specific date and a time - showing then months, days, hours and seconds.

Thanks.

tippi
06-15-2005, 04:01 PM
got the answer, thanks

huntsharks
07-31-2005, 02:20 PM
hey. can someone send me the edited code which starts from a specific time and shows d h m s

tippi
08-01-2005, 02:29 PM
Here's the countup script - it works. Just cut and paste, follow the instructions.

Bob

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

</head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Bob's countup script</title>

<body>
<p>It's been


<script language="JavaScript1.2" type="text/javascript">function setcountup(theyear,themonth,theday){
yr=theyear;mo=themonth;da=theday
}

//////////CONFIGURE THE countup SCRIPT HERE//////////////////

//STEP 1: Configure the date to count up from, in the format year, month, day:
//This date should be less than today
setcountup(2005,8,01)

//STEP 2: Configure text to be attached to count up
var displaymessage="since Bob stopped smoking on August 1st, 2005 at 10am ."



//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countup area
var countupwidth='90%'
var countupheight='40px' //applicable only in NS4
var countupbgcolor=''
var opentags='<font face="Verdana"><large>'
var closetags='</large></font>'

//////////DO NOT EDIT PASS THIS LINE//////////////////

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''

function start_countup(){
if (document.layers)
document.countupnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countupie") : countupie
countup()
}

if (document.all||document.getElementById)
document.write('<span id="countupie" style="width:'+countupwidth+'; background-color:'+countupbgcolor+'"></span>')

window.onload=start_countup


function countup(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
paststring=montharray[mo-1]+" "+da+", "+yr
paststring="10:00"+montharray[mo-1]+" "+da+", "+yr
dd=Date.parse(todaystring)-Date.parse(paststring)
dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)

if (document.layers){
document.countupnsmain.document.countupnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+displaymessage+closetags)
document.countupnsmain.document.countupnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+displaymessage+closetags

setTimeout("countup()",1000)
}
</script>
<p> COUNTUP SCRIPT</p>
</body>
</html>

Twey
08-01-2005, 02:36 PM
2,500 views of this?!

tippi
08-01-2005, 02:53 PM
The script does work, right? so I guess it's a popular question. Am I missing your point?

Bob

Twey
08-01-2005, 03:39 PM
I was just wondering why we'd only just reached the second page.

Feckie
12-09-2005, 05:23 PM
YMHMS script i'm afraid. I just couldn't get days to work, because of this:

To get years we divide days by 365
To get months we divide years by 12 and take off the amount of months already stated for in the years, easy enough
But to get days in this context, we need to take the months and years already stated in the previous two... and its too late at night for me to handle this! (edit: by the way, I'm in GMT. It's not really 8:00 PM.)

Still, here's the YMHMS script.



<script language="JavaScript1.2">

//Dynamic countup Script- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com

function setcountup(theyear,themonth,theday){
yr=theyear;mo=themonth;da=theday
}

//////////CONFIGURE THE countup SCRIPT HERE//////////////////

//STEP 1: Configure the date to count up from, in the format year, month, day:
//This date should be less than today
setcountup(1999,3,2)

//STEP 2: Configure text to be attached to count up
var displaymessage="have passed since the debut of our site!"

//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countup area
var countupwidth='95%'
var countupheight='20px' //applicable only in NS4
var countupbgcolor='lightyellow'
var opentags='<font face="Verdana"><small>'
var closetags='</small></font>'

//////////DO NOT EDIT PASS THIS LINE//////////////////

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''

function start_countup(){
if (document.layers)
document.countupnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countupie") : countupie
countup()
}

if (document.all||document.getElementById)
document.write('<span id="countupie" style="width:'+countupwidth+'; background-color:'+countupbgcolor+'"></span>')

window.onload=start_countup


function countup(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
paststring=montharray[mo-1]+" "+da+", "+yr
dd=Date.parse(todaystring)-Date.parse(paststring)
dyear=Math.floor(dd/(60*60*1000*24*365)*1)
dmonth=Math.floor(dd/(60*60*1000*24*12)/(dyear*12))
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)

if (document.layers){
document.countupnsmain.document.countupnssub.document.write(opentags+dyear+" years, "+dmonth+" months, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+displaymessage+closetags)
document.countupnsmain.document.countupnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+dyear+" years, "+dmonth+" months, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+displaymessage+closetags

setTimeout("countup()",1000)
}
</script>

<ilayer id="countupnsmain" width=&{countupwidth}; height=&{countupheight}; bgColor=&{countupbgcolor}; visibility=hide><layer id="countupnssub" width=&{countupwidth}; height=&{countupheight}; left=0 top=0></layer></ilayer>


If you'll excuse me, I have to collapse now. :)

cr3ative



Is it possible to have the years showing in this as well

Would be gratefull :D

Twey
12-09-2005, 07:37 PM
Um... they already do?

yo-less
12-15-2005, 12:28 PM
Hey everyone. This script is awesome! Could anyone assist me with modifying it so that it differentiates between 1 second and several secondS, i.e. so that the script shows "second" when it is 1 second and "seconds" all the other time? Would really appreciate your help =)

Vagele
01-21-2006, 10:23 PM
can anyone tell me how to count up only minutes ??? my site have live score and i want to count up 45 minutes. but i want to put this counter where i want and with the style that i want. if anyone knows let me know. i want it for tommorow if it is possible. thanks!!!

carineb
07-03-2007, 03:18 PM
Thanks for this great script!

Anybody has any idea why my page lookes fine in Internet Explorer but instead of a number the value NaN is returned in Firefox and Safari.

As far as I know the latest version of Java is installed on my computer (at least where I'm running Firefox). Is there anything I should change to the script in order to return correct values in other browsers too?

Twey
07-03-2007, 05:22 PM
carineb, we'd have to see your page to make a judgement. The version of Java you may have installed has nothing to do with Javascript.

carineb
07-03-2007, 05:32 PM
Hi Twey (and others of course!),

this is the URL to my page: http://users.pandora.be/carineb/arne/title.htm

You want me to paste the code here?

Thanks already for wanting to look at it!
Carine

Twey
07-03-2007, 05:48 PM
You have this code on your page:
paststring=montharray[mo-1]+" "+da+", "+yr
paststring="10:00"+montharray[mo-1]+" "+da+", "+yrThe latter statement -- which I presume you've inserted yourself, since you seem to have done some localisation elsewhere in the script -- sets paststring to a string in an invalid format. You probably want:
paststring=montharray[mo-1]+" "+da+", "+yr+" 10:00"... and you can remove the former line entirely, since you currently overwrite it anyway.

You have bigger problems, though: your page is completely invalid (http://validator-test.w3.org/check?uri=http&#37;3A%2F%2Fusers.pandora.be%2Fcarineb%2Farne%2Ftitle.htm).

carineb
07-03-2007, 05:59 PM
Hi Twey,

actually I didn't change that particular line, I did change some other lines as you've noticed.

I'm a novice in Java, all I was looking for was a counter to show my sons age on his website.

I'll try to correct the problems and if needed start all over again from the example scripts. It might be possible you'll see more questions coming along ;-)

Thanks for your fast and helpfull replies!
Carine

carineb
07-03-2007, 07:57 PM
Everything is working now, thanks again!

alanbarn
02-29-2008, 04:50 AM
Anyone got the script for

years months days hours minutes seconds

I want the output to read:

'Max is 1 year 1 month 14 days 12 hours 45 minutes 36 seconds old'

doesn't matter if the singular vs plural is too hard, 1 years, 1 months, 1 days etc will do

as you can prolly guess it's for my a website I've set up for my son.

alanbarn
07-04-2008, 06:17 AM
bump!

Heart
03-22-2010, 06:08 PM
script does not print the years; I need a script that prints the years along with the rest