Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding my birthday wasnt meant to be this hard ...

Status
Not open for further replies.

Jonnn

Programmer
Nov 17, 2004
135
GB
Ok guys, This script i made is trying to tell me i was born on a different day ... but the code seems perfect ...

it works if i was born in nearly any year besides 1987 ???

take a look

Code:
<html>
<head>
<title>sample</title>

<script language="javascript">

var my_birthday 	= new Date("August 26, 1987"); 			
var a_year 		= 86400000 * 365;    
var eighteen_years 	= a_year * 18;					
var time_passed 	= my_birthday.getTime();				
var when_am_18 		= new Date(time_passed + eighteen_years);
	
alert("You are 18 on the date : " + when_am_18);						

</script>
</head>

<body>


</body>
</html>

Any ideas would be much appreciated, thanks !

- Jon

JavaScript Beginner at work :)
 
Huh? Try this:

Code:
<script language="javascript">

var my_birthday = new Date("August 26, 1987");  
my_birthday.setYear( my_birthday.getFullYear() + 18 );
alert("You are 18 on the date : " + my_birthday);                        

</script>

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top