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 6348493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:25:47+00:00 2026-05-24T21:25:47+00:00

I am showing the value of the timer.php through AJAX in index.php . However

  • 0

I am showing the value of the timer.php through AJAX in index.php . However I am concern about the performance of this, if it is a server killer if there are 30 people online, and things like this. Do you suggest me some edits?

Thank you.

index.php

<script language='JavaScript'>
setInterval( 'SANAjax();', 1000 );

$(function() {
SANAjax = function(){

$('#dataDisplay').load('timer.php');

}
 });

</script>
<div id="dataDisplay"></div>

timer.php

function time_difference($endtime){
    $days= (date("j",$endtime)-1);
    $hours =date("G",$endtime);
    $mins =date("i",$endtime);
    $secs =date("s",$endtime);
    $diff="'day': ".$days.",'hour': ".$hours.",'min': ".$mins.",'sec': ".$secs;
    return $diff;
}   

$future_time = mktime(0, 0, 0, 9, 19, 2011);
$now_time = strtotime("+2 hours");
$end_time = $future_time - $now_time;
$difference = time_difference($end_time);
if ($future_time <= $now_time ) { echo "Date reached"; } else { echo $difference; };
?>
  • 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-24T21:25:48+00:00Added an answer on May 24, 2026 at 9:25 pm

    Depends on your server specs and number of clients, this could quickly become a server-killer.

    The multiple calls to a file every second will quickly put a lot of load for nothing though, so best practice calls for using a javascript timer countdown. I particularly like this one: http://stuntsnippets.com/javascript-countdown/

    And for the jQuery implementation:

    <script type="text/javascript">
    var myDate = new Date(); //Retrieve actual date
    myDate.setTime(this.getTime() + (3600 * 2)); //Add two hours
    
    $(document).ready(function() {
        $("#time").countdown({
            date: myDate.toGMTString(),
            onComplete: function( event ){
                $(this).html("completed");
            },
            leadingZero: true
        });
    });
    </script>
    
    <p id="time" class="time"></p>
    

    This should be enough, no more need for PHP calls and the client does everything.

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

Sidebar

Related Questions

I am showing the value in the textbox.The value comes from the database first
I feed a textbox a string value showing me a balance that need to
When showing data from a mysql table on an php page does it have
<form action=here.php method=POST> <input type=text name=text> <div id=one> <input type=hidden name=aaa value=one> <input type=submit
I have a chart with X-axis showing timeline and Y-axis showing value for an
I am using php/ajax to submit a form without page refresh. Here are my
I'm attempting to work on this form, at this time it is showing me
I have tables as posted in this question . •Measurements (MeasureID, Time, Distance, Value)
In the event viewer in windows 2008, the events XML are showing this: <TimeCreated
I have tried to pass a value from the id attribute in my php

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.