Ryflex Posted September 25, 2010 Share Posted September 25, 2010 Hi all, I got a javascript of the net and integrated it within my php file. After refreshing the page the timer gets higher everytime. I echo'd the input variable on the same page and that gives the correct input in seconds. Script: <script type="text/javascript"> var nIndex = '<?php echo "$time_difference"; ?>'; // 35 days, in seconds; var GMToffset = 0; // your current GMT offset; var refDate = new Date(); // start date; refDate = new Date(refDate.getFullYear(), refDate.getMonth(), refDate.getDate(), refDate.getHours(), refDate.getMinutes(), refDate.getSeconds()+nIndex, 0); var done = false; function init(){ var currDate = new Date(); currDate.setHours(GMToffset+currDate.getHours()+currDate.getTimezoneOffset()/60); if (refDate < currDate) { document.getElementById('display').innerHTML = "This auction is closed."; done = true; } var remTime = refDate-currDate; var nDays = parseInt(remTime/86400000); var nHours = parseInt((remTime-(nDays*86400000))/3600000); var nMin = parseInt((remTime-(nDays*86400000)-(nHours*3600000))/60000); var nSec = 0; if (refDate > currDate) { nSec = 60-(currDate.getSeconds()); } else { nSec = currDate.getSeconds(); } var nMonths = parseInt(nDays/30); var rDays = parseInt(nDays-(nMonths*30)); if (!done) { setTimeout("init()", 1000); document.getElementById('display').innerHTML = nMonths + " Months, " + rDays + " Days, " + nHours + " Hours, " + nMin + " Minutes, " + nSec + " Seconds"; } } navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false); </script> <style type="text/css"> body {margin-top: 0px;} .timer_countdown {width: 460px; margin-left: auto; margin-right: auto; margin-top: 0px; text-align: center; font-family: 'times new roman'; font-size: 12pt; color: #FFFFFF; background-color: #002b4d; padding-bottom: 3px;} </style> </head> <body> <center><h1><?php echo"$building" ?></h1></center> <table width="500" border="1" align="center" cellpadding="2" cellspacing="0"> <tr> <td><b>Building</b></td> <td><b>Level</b></td> <td><b>Upgrade</b></td> </tr> <tr> <td><a href="link"><?php echo"$building" ?></a></td> <td><?php echo "$building_level";?></td> <td><div class="timer_countdown" id="display"></div></td> <td><a href="link">Upgrade!</a></td> </tr> </table> </body> </html> thnx Ryflex Quote Link to comment Share on other sites More sharing options...
Ryflex Posted September 26, 2010 Author Share Posted September 26, 2010 Can anyone help me???? please... Quote Link to comment Share on other sites More sharing options...
Ryflex Posted September 28, 2010 Author Share Posted September 28, 2010 Anyone. please ppl I'm really stuck here Ryflex Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.