GetDotted Domains

Viewing Thread:
"Age Javascript"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Tue 09/01/07 at 21:18
Regular
"tinycurve.gif"
Posts: 5,857
Many thanks to cjh for fixing my table background rollover issue.

Now I'm on to the personal part of my site, which is a single page about me. The rest may be revealed later.

So anyway, what I want is a simple javascript which calculates my age in years. I'm thinking along the lines of my year of birth being set in a variable, even though that variable will not change, and a simple mathematical equation which deducts my year of birth from the current year, resulting in my age.

Would anyone be able to do that for me?

Muchos danke, mes ami. :)
Wed 10/01/07 at 17:25
Regular
"tinycurve.gif"
Posts: 5,857
Okie doke. Thanks a lot!
Tue 09/01/07 at 23:01
Regular
"Devil in disguise"
Posts: 3,151
Yup, as Bob said you'd put 10 for october.
Tue 09/01/07 at 22:36
Regular
"Tornado Of Souls"
Posts: 5,680
Looks like Garin has sorted it out for you by incrementing the month value, so you'd just use 10.
Tue 09/01/07 at 22:24
Regular
"tinycurve.gif"
Posts: 5,857
Assuming my birthday is October, would the number for that month be 9 or 10? I know that months in JavaScript go from 0 to 11, not 1 until 12.

Or have you sorted this problem already for me so that I just set the month to 10?
Tue 09/01/07 at 22:05
Regular
Posts: 19,415
Ah ha! Big mistake Garin, now I know when you were born! Lets see.. the 13th June 198... oh, nevermind =(

[S][S]I'll discover your real identity one day Garin. Just you wait![/S][/S]

Nice code by the way *tempted*
Tue 09/01/07 at 21:52
Regular
"Devil in disguise"
Posts: 3,151
Something like this I think...

<script language="JavaScript" type="text/javascript">

var BirthDay=13;
var BirthMonth=6;
var BirthYear=1980;

var now=new Date();
var CurrDay=now.getDate();
var CurrMonth=now.getMonth()+1;
var CurrYear=now.getFullYear();
var MyAge=CurrYear-BirthYear-1;
if ((BirthMonth<CurrMonth) || ((BirthMonth==CurrMonth) && (BirthDay<=CurrDay))) {
MyAge++;
}
document.write('My Age is '+MyAge);
</script>


I suppose you can guess to change the 3 variables at the top with your own birthday.
Tue 09/01/07 at 21:18
Regular
"tinycurve.gif"
Posts: 5,857
Many thanks to cjh for fixing my table background rollover issue.

Now I'm on to the personal part of my site, which is a single page about me. The rest may be revealed later.

So anyway, what I want is a simple javascript which calculates my age in years. I'm thinking along the lines of my year of birth being set in a variable, even though that variable will not change, and a simple mathematical equation which deducts my year of birth from the current year, resulting in my age.

Would anyone be able to do that for me?

Muchos danke, mes ami. :)

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Excellent support service!
I have always found the support staff to provide an excellent service on every occasion I've called.
Ben
I've been with Freeola for 14 years...
I've been with Freeola for 14 years now, and in that time you have proven time and time again to be a top-ranking internet service provider and unbeatable hosting service. Thank you.
Anthony

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.