JavaScript for counting days

news about changes and fixes to the board, and a place to post any technical queries.

Moderator: staff

Post Reply
User avatar
Laura
board admin emeritus
board admin emeritus
Posts: 8676
Joined: Mon Nov 19, 2001 1:00 am
Location: Scotland
Contact:

JavaScript for counting days

Post by Laura » Sat Jul 03, 2004 9:01 pm

Hiya

Just sharing this Java script I found at http://www.javascriptkit.com that can be used on your web page to count your number of days SI-free.

Code: Select all

<script>
/*
Count up from any date script-
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free scripts here!
*/

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("I am "+difference+" self-injury free!")
}
//enter the count up date using the format year/month/day
countup(2003,07,15)
</script>
Change the "(2003,07,15)" near the bottom to the day after you last SIed, and the wording in the "document.write" part to whatever you choose. I don't think it will work in BUS posts, but you can put it on your website. It just appears in ordinary text - it's on my site if you want to see how it looks.

Maybe lots of techie people out there will have better ideas - I know nothing about java, well except this sort --> :java:

Laura :blush:

User avatar
guest11
staff member emeritus
staff member emeritus
Posts: 3984
Joined: Thu Apr 24, 2003 6:35 pm

Post by guest11 » Sat Jul 03, 2004 11:16 pm

It won't work in BUS posts. I asked about something similar before. Nice find, however. :)

User avatar
goth barbie
spiffy maximus
spiffy maximus
Posts: 4390
Joined: Tue Jul 20, 2004 5:54 am
Location: aBeerCan (Canberra)
Contact:

Post by goth barbie » Tue Aug 03, 2004 1:42 pm

wow

User avatar
metzli
creating your space
creating your space
Posts: 203
Joined: Mon Sep 23, 2002 11:49 pm
Location: Minnesota
Contact:

Post by metzli » Wed Aug 04, 2004 3:52 am

Check this out:get your own time counter

I made it myself! :)

metzli
I have been SI-free for Image
get your own counter

I have Image hugs
send me a hug
get hugs of your own

User avatar
guest11
staff member emeritus
staff member emeritus
Posts: 3984
Joined: Thu Apr 24, 2003 6:35 pm

Post by guest11 » Wed Aug 04, 2004 4:03 pm

That's pretty damn good! Well done :)

User avatar
Laura
board admin emeritus
board admin emeritus
Posts: 8676
Joined: Mon Nov 19, 2001 1:00 am
Location: Scotland
Contact:

Post by Laura » Sun Aug 08, 2004 3:57 pm

Oh wow, that's fantastic! :grnteeth:
Thanks Metzli :1hug:
Laura :java:
<center>
I feel <a href="http://www.imood.com/users/snail"><img src="http://moods.imood.com/display/uname=sn ... /imood.gif" alt="The current mood of snail at imood.com" border="0"></a>

<a href="http://www.irrepressible.info"><img src="http://uk.geocities.com/floor_sitter/im ... nner_5.gif" alt="Irrepressible.info"></a></center>

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests