Clan FJA Posted May 25, 2015 Posted May 25, 2015 Hello, I'm a noob in Html, and i try to display a customised date on my forum.The goal is to convert the real date of the user into a "RP date". For example, 2 real days = 1 RP week7 RP week = 1 RP month10 RP month = 1 RP year The calendar start from the real date named "geonosis". I calculate the difference of days between this date and the actual date, and then I convert this number into RP months, years and weeks. I read some tutorials about date in Html and javascript, and tried to build this script : <script type="text/javascript"> function galacticdate(){ var geonosis = new Date(2015,5,25); var rdate = new Date().toString(); var rdiff = rdate.getTime() - geonosis.getTime(); var gyear=1; var gmonth=1; var gweek=1; var jourconv=1000*60*60*24; rdiffjour = Math.ceil(rdiff/jourconv); while (rdiffjour > 140) { gyear = gyear + 1; rdiffjour = rdiffjour - 10*14; } while (rdiffjour > 14) { gmonth = gmonth + 1; rdiffjour = rdiffjour - 14; } while (rdiffjour > 2) { gweek = gweek + 1; rdiffjour = rdiffjour - 2; } var galacticdisplay = 'An '+gyear+ ', mois '+gmonth+', semaine '+gweek+' de la Guerre des Clones'; document.getElementById("galactictimer").innerHTML = galacticdisplay; return } </script> <body onload="galacticdate();"> <div id="galactictimer"></div> However, it doesnot work. Nothing is displayed. someone could help me ?
Link Posted May 25, 2015 Posted May 25, 2015 I am no expert with Javascript, but that script seems to be just calculating something, not writing anything. You'll need to set up some document.write's or console.log's, that's IF the script is working correctly
Solution redsaurus Posted May 25, 2015 Solution Posted May 25, 2015 rdateshould just be new Date();not new Date().toString();
Didz Posted May 25, 2015 Posted May 25, 2015 The browser's developer tools are also invaluable when debugging problems in your code. Just press F12 and click the Console tab, any warnings and errors will be shown there.
Clan FJA Posted May 25, 2015 Author Posted May 25, 2015 rdateshould just be new Date();not new Date().toString(); Thank you a lot ! It works Now, there is another problem : When I try with 20 April 2015 for the starting date, I should get a difference of days about 35 days (with today, 25 May 2015)However, I get 6 days only !!!! var geonosis=new Date(2015,04,20,0,0,0,0); var rdate=new Date(); var rdiff=rdate.getTime()-geonosis.getTime(); It seems there is a problem here.When I test, rdiff is 516847066 / 1000*60*60*24 = 5,98 days in place of 35....
hleV Posted May 26, 2015 Posted May 26, 2015 Check rdate's value. It's possible that the machine you're running this script on doesn't have time configured properly.
Clan FJA Posted May 26, 2015 Author Posted May 26, 2015 Hello ! rdate is ok, the problem was geonosis. Strangely, date(2015,04,20) gives the 20 May 2015, and date(2015,03,20) gives the 20 April 2015....So January is 0 and not 1... stupid trap.... Thank you all.Now, I just must find someone who can convert .ase into .md3 and I will be very happy
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now