Click to See Complete Forum and Search --> : i need help


eureks
07-24-2003, 08:35 PM
i have to write a program which expects a user to enter three pieces of information month, day, year in the form of 02 12 2001. my program have to return the number of days that have elapsed since the date entered and january 1 of the year entered. do you have any suggetions on how i can go about doing this?

Khalid Ali
07-24-2003, 09:33 PM
what you will need to do is
get the date1
get the date2

One the dates above could be from system..
if you cate a date from user then convert that to a date object using
vare date1 = new Date(dateStr);
read date object details at here
http://devedge.netscape.com/library/manuals/2000/javascript/1.5/guide/obj.html#1008512

now convert both dates into milliseconds,

then subtract the prev date from the current date

then convert the milli secs into days(because thats what you want to know
here is how
suppose the difference after sbtraction was
newDate;//this is milli secs
var days = (Math.floor(newDate/(1000*60*60*24)));

eureks
07-24-2003, 10:33 PM
thank you so much i will try this and see if it works