PDA

View Full Version : "Countup" timer format Help Needed


caclark
10-09-2002, 03:38 PM
I have been looking on several of the free javaware sites for a "countup" timer, but so far they all seem to be very similar, even to the point of their output "days".

I however need to "countup" from a given day, but have the output be in a little more recignized format (month,day,year), not thousands of days.

Sample code:

<script>

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

function countup(yr,m,d){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy
var paststring=montharray[m-1]+" "+d+", "+yr
var difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1)
difference+=" days"
document.write("The record was created "+difference+" ago")
}

countup(1997,12,05)
</script>



Any ideas or help would be greatly appreciatted.