This is just simple stuff I know, but I need help with it please. As you can see below I have asked for the DOB to be entered, but how do I get it to work out the persons age from their DOB to todays date?
var canvas;
canvas = openGraphics();
var phrase;
phrase = "Your name:";
var phrase2;
phrase2 = "Your Date of birth:";
var phrase3;
phrase3 = "Your mobile number:";
var phrase4;
phrase4 = "your email address:";
var name;
name = prompt("Please enter your name");
var DOB;
DOB = prompt("Please enter your date of birth DD/MM/YY");
var mobile;
mobile = prompt("Please enter your mobile number");
var email;
email = prompt("Please enter your email address");
var message;
message = phrase + name;
var message2;
message2 = phrase2 + DOB;
var message3;
message3 = phrase3 + mobile;
var message4;
message4 = phrase4 + email;
canvas.drawString( message, 10, 10);
canvas.drawString( message2, 10, 30);
canvas.drawString( message3, 10, 50);
canvas.drawString( message4, 10, 70);
canvas.paint();
5 1742
Use
then see this page to see how you can use the Date object,
DOB = prompt("Please enter your date of birth DD/MM/YY",''); - try{
-
var D=DOB.split(/\W+/);
-
for(var i=0;i<3;i++){
-
D[i]=Number(D[i]);
-
}
-
--D[1];
-
var age= new Date()- new Date(D[2],D[1],D[0]);
-
age= Math.floor(age/3.15576e10);
-
}
-
catch(er){
-
DOB = prompt("Enter digits for the day, month and year, separated by / characters",'');
-
}
MrHoo, let me guess, 3.15576e10 is the number of seconds in a millennium, right?
MrHoo, let me guess, 3.15576e10 is the number of seconds in a millennium, right?
Yes, but it is also the number of milliseconds in 365.25 days:
1000*60*60*24*365.25=31557600000
Yes, but it is also the number of milliseconds in 365.25 days:
1000*60*60*24*365.25=31557600000
Aah, that makes more sense. Thanks.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kamliesh Nadar |
last post by:
Hi
I am developing a software using VB.NET I am facing
following problems -
1. Though I have placed the NotifyIcon control on the
window service application, after starting the service I
am...
|
by: Art |
last post by:
Hello everyone,
I am interested in starting an all volunteer website which will be directed
at recovering missing children. I am aware that there are few other sites
out there with the same...
|
by: el prinCipante |
last post by:
I'm getting tired of the following error message.
Compiler Error message : Error: Need explicit cast to convert
from: float
to: float *
I am trying to use a routine from the Numerical Recipes...
|
by: senthilkumaramani |
last post by:
Hi EveryBody,
I am using wixdows Xp.
In my machine whenever i run the .net webapplication for that time i did't work internet.
If i want to access internet means i do the following options....
|
by: Joonshik Kim |
last post by:
I was trying to define 3d array with pointer to pointer. I wrote like
following.
int ***d;
nx = 3;
ny = 5;
nz = 4;
d = (int ***)malloc((int) nx*sizeof(int **));
*d = (int **)malloc((int)...
|
by: janakivenk |
last post by:
Hello,
I am running Oracle 10g R2 in our office. I created the following procedure. It is suppose to access an xml file ( family.xml). The procedure is compiled and when I try to run it, i get the...
|
by: itskaps |
last post by:
Hi all,
My following program code works fine on win 2K server but the same is not working on win2K3 server. It's showing error as page cannot be displayed. After debugging, I found that...
|
by: crack.the.hack |
last post by:
Hi All,
If I am changing the database machine, what should I do not to prep
bind the sqc files everytime.
Because I need to build my application everytime the database is
changed?
Is there...
|
by: Robert Wells |
last post by:
Gentlemen,
We are looking for two IBM documents that are needed urgently for a
project. They are titled "4680 Store Systems Serial I/O Channel Attachment
Information" and "Serial I/O Product...
|
by: uhdam |
last post by:
Hai...
I need to have image as tooltip. Is it possible. If yes how. I dont want to use applet. When i scroll over the label in my frame the pop up containing the image should be displayed. How can...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |