Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7607143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:35:16+00:00 2026-05-31T00:35:16+00:00

I have this code: <script type=text/javascript> var currenttime = ‘<? print date(F d, Y

  • 0

I have this code:

<script type="text/javascript">
var currenttime = '<? print date("F d, Y H:i:s", time()) ?>'
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var serverdate=new Date(currenttime)

function padlength(what){
var output=(what.toString().length==1)? "0"+what : what
return output
}

function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
var datestring=montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+", "+serverdate.getFullYear()
var timestring=padlength(serverdate.getHours()+1)+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds())
var minleft=60-serverdate.getMinutes()
var secleft=60-serverdate.getSeconds()
var houleft=24-serverdate.getHours()+1
var newenergyin=padlength(minleft)+":"+padlength(secleft)
var gainin=padlength(houleft)+":"+padlength(minleft)+":"+padlength(secleft)
document.getElementById("servertime").innerHTML=timestring
document.getElementById("moreenergy").innerHTML=newenergyin
document.getElementById("inter").innerHTML=gainin
}

window.onload=function(){
setInterval("displaytime()", 1000)
}
</script>

I am having an issue with the

document.getElementById("inter").innerHTML=gainin

part of the code. If I do

<span id='inter'></span>

it doesn’t want to work, but the previous one I made with

document.getElementById("moreenergy").innerHTML=newenergyin

works absolutely fine.

What am I doing wrong?! All I want is to show a countdown to midnight, the countdown till the next hour works fine :S

HTML:

<td><center><b>- Currency -</b></center>Credits: <a href='main.php?id=depcre'>0</a>    
<br>Platinum: <font color='orange'>46</font><br>Waste Magic: <font color='orange'>48</font>    
<br>Copper: <font color='orange'>49</font><br>Silver: <font color='orange'>48</font>    
<br>Gold: <font color='orange'>47</font><br><br>Bank: <a href='main.php?id=witcre'>841</a>    
<Small> (<font color='orange'>0.25%</font> IGDA)</small><br>Interest Gain In: <font     color='orange'><span id='inter'></span></font></td>

OK, Entire HTML:

<script type="text/javascript">
var currenttime = '<? print date("F d, Y H:i:s", time()) ?>'
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var serverdate=new Date(currenttime)

function padlength(what){
var output=(what.toString().length==1)? "0"+what : what
return output
}

function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
var datestring=montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+", "+serverdate.getFullYear()
var timestring=padlength(serverdate.getHours()+1)+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds())
var minleft=60-serverdate.getMinutes()
var secleft=60-serverdate.getSeconds()
var houleft=24-serverdate.getHours()+1
var newenergyin=padlength(minleft)+":"+padlength(secleft)
var gainin=padlength(houleft)+":"+padlength(minleft)+":"+padlength(secleft)
document.getElementById("servertime").innerHTML=timestring
document.getElementById("moreenergy").innerHTML=newenergyin
document.getElementById("inter").innerHTML=gainin
}

window.onload=function(){
setInterval("displaytime()", 1000)
}

</script>
    <tr>
        <td><center><b>- Stats [<a href='main.php?id=<?php echo $page;?>'>Refresh</a>] -</b></center>Level: <font color='orange'><?php echo $GETVAR[PL_LEVL]; ?></font><br>Experience: <font color='orange'><?php echo $GETVAR[PL_CUREXP]; ?></font>/<font color='orange'><?php echo $GETVAR[PL_NEXEXP]; ?></font><br>Energy: <font color='orange'><?php echo $GETVAR[PL_CURENG]; ?></font>/<font color='orange'><?php echo $GETVAR[PL_NEXENG]; ?></font><br>Skill: <font color='orange'><?php echo $GETVAR[PL_SKILL]; ?></font><br>HP: <font color='orange'><?php echo $GETVAR[PL_CURHP]; ?></font>/<font color='orange'><?php echo $GETVAR[PL_MAXHP]; ?></font><br>Hit Rate: <font color='orange'><?php echo $GETVAR[PL_HITRATE]; ?></font><br>
<?php
$cureng = $GETVAR['PL_CURENG'];
$nexeng = $GETVAR['PL_NEXENG'];
$curhit = $GETVAR['PL_CURHP'];
$maxhit = $GETVAR['PL_MAXHP'];
if(($cureng == $nexeng) && ($curhit == $maxhit))
{
    echo "<br>";
}else
{
    echo "Energy and HP Increase in: <font color='orange'><span id='moreenergy'></span>    </font>";
}


?></td>
    </tr>
    <tr>
        <td><center><b>- Currency -</b></center>Credits: <a href='main.php?    id=depcre'><?php echo $GETVAR[PL_CRED]; ?></a><br>Platinum: <font color='orange'><?php echo     $GETVAR[PL_PLAT]; ?></font><br>Waste Magic: <font color='orange'><?php echo     $GETVAR[PL_WAMA]; ?></font><br>Copper: <font color='orange'><?php echo $GETVAR[PL_COPP]; ?>    </font><br>Silver: <font color='orange'><?php echo $GETVAR[PL_SILV]; ?></font><br>Gold:     <font color='orange'><?php echo $GETVAR[PL_GOLD]; ?></font><br><br>Bank: <a href='main.php?    id=witcre'><?php echo $GETVAR[PL_BANK]; ?></a><Small> (<font color='orange'><?php echo     $GETVAR[PL_INTR]*10;?>%</font> IGDA)</small><br>Interest Gain In: <font color='orange'>    <span id='inter'></span></font></td>
    </tr>
    <tr>
        <td><center><b>- You -</b></center>
                <a href='main.php?id=news'>News</a><br>
                <a href='main.php?id=yourhome'>Your Home</a><br>
                <a href='main.php?id=yourmage'>Your Mage</a><br>
                <a href='main.php?id=puppets'>Your Puppets</a><br>
                <a href='main.php?id=enchants'>Your Enchants</a><br>
                <a href='main.php?id=clan'>Your Clan</a><br>
                <a href='main.php?id=pm'>Mailbox</a></td>
    </tr>
    <tr>
        <td height=100%>    <center><b>- Navigation -</b></center>
                <a href='main.php?id=townarea'>Town of Tolbart</a><br>
                <a href='main.php?id=skilupgr'>Skill Upgrades</a><br>
                <a href='main.php?id=colloseu'>Colloseum</a><br>
                <a href='main.php?id=wastmagi'>Waste Magic Center</a><br>
                <a href='main.php?id=field'>Field</a><br>
                <a href='main.php?id=market'>Market</a><br>
                <a href='main.php?id=gather'>Gathering</a><br>
                <a href='main.php?id=darkmagi'>Dark Magic Workshop</a><br>
                <a href='main.php?id=research'>Research Facility</a><br>    <br>
                <a href='main.php?id=logout'>Log Out</a>

<br>Game Time: <span class="servertime" id="servertime"></span>
</td>
            </tr> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:35:17+00:00Added an answer on May 31, 2026 at 12:35 am

    I’ve removed all the php from the question to make it more simple. It seems that your java script runs fine.

    You can see it running on my js fiddle

    NOTE:

    You can you the javascript Date() class instead of getting the date from php.

    Also try not to use a string in setInterval (setinterval uses eval on the string). Trying using the following instead

    setInterval(function(){displaytime()}, 1000)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I have this code: <script language=javascript type=text/javascript> <!-- function requestPage(page) { var request
i have this code: <script type=text/javascript> var str=KD-R35H2UND; var patt1=/[G|T|EE|EJU].*D/i; document.write(str.match(patt1)); </script> by using
I have this code: <script type=text/javascript> var loader = #loader; $(function() { $(#selUsers).change(function() {
I have this code: <script type=text/javascript> function showTotal(form, totalEl) { var el, els =
I have this code: <script type=text/javascript> function js() { var getJs = document.getElementById(jogo); if
i have this code: <script type=text/javascript> $(document).ready(function() { function doAjax(url) { $(#customForm).submit(function() { var
I have this jQuery code: <script type=text/javascript > $(function() { $('#add_comment').bind('submit',function() //$(input[type=submit]).click(function() { var
I have this java code: <script src=http://www.google.com/jsapi></script> <script type=text/javascript> google.load(jquery, 1.2.6); $(a#more).click(function() { $(#info_box).show(blind,
I have this html code <html> <head> <title>JQuery Problem 2</title> <script type=text/javascript src=jquery-1.4.min.js></script> <script
The code is like this: var script = document.createElement('script'); //script.type = 'text/javascript'; // do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.