Sport Betting Bonuses - Debt Consolidation - Deaf Topics - Valentine Gifts - Property in Brazil

PDA

View Full Version : Days until my birthday script


zk0
Feb 19th 2007, 2:38 am
Hi everyone!

I need some help with this javascript. I just don't seem to understand how to code it properly.

The code is suppose to let the user enter which month his birthday is on and which day, then the script would tell the user how many days it is until his birthday. But I don't know how to code that. This is what I need help with:

I know that if I count todays ms seconds subtraction with the ms for the users birthday and then convert that to days I will know how many days it's left to the users birthday.

This is the code I got so far:

var minusEtt = Number( prompt('What month is your birthday (1-12)?','') );
var date = Number( prompt('What day is your birthday (1-31)?','') );

var month = minusEtt - 1 ; // the month - one

var nextBirthday = new Date( month, date, 0, 0, 0, 0 ) // month, date, hour, min, sec, ms

var todaysDate = new Date(); // Todays date

zk0
Feb 19th 2007, 10:10 am
Okey, I have updated the code. It now looks like this. What have I done wrong that makes the code not to write out?

var minusEtt = Number( prompt('What month is your birthday (1-12)?','') );
var date = Number( prompt('What day is your birthday (1-31)?','') );

var month = minusEtt - 1 ; // the month - one

var nextBirthday = new Date( month, date, 0, 0, 0, 0 ) // month, date, hour, min, sec, ms

var todaysDate = new Date(); // Todays date

myDate.getTime();

var skillnad = nextBirthday.getTime() - todaysDate.getTime();

var skrivUt = skillnad / 1000 / 60 / 60 / 24 ;

document.write( skrivUt.toString( ) )

zk0
Feb 20th 2007, 7:54 am
Anyone have any idea to why the script doesnt output days. Now it only outputs ms? :confused:

zk0
Feb 20th 2007, 12:04 pm
This problem is now solved! :D