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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:04:58+00:00 2026-06-10T00:04:58+00:00

I have a problem with my website. I have create a countdown timer with

  • 0

I have a problem with my website. I have create a countdown timer with php code and JS.

My problem is when I echo my variable abc. it’s ok(echo the right timestamp) but when i find the real end time by using “end time from DB – server currentime + client time” then echo it. The result is only “end time from DB – server currentime” How can i fix this issue?

JS

 </script>  
<script type="text/javascript">
var get_client_time = Math.round(new Date().getTime()/1000);

<?php $abc = "<script>document.write(get_client_time)</script>"?>   
</script>

PHP code

  echo $abc . "</br>";
  $show=mysql_query("SELECT * FROM `room_lists` WHERE `active` = 1");
    while ($array = mysql_fetch_array($show))
    {
        $room_number = $array['room_number'];
        $room_name = $array['room_name'];
        $subject = $array['subject'];
        $s_group = $array['s_group'];
        $active = $array['active'];

        $timeStop = $array['timeStop'];

        //find real ending time
        $endDay = $abc + strtotime($timeStop)-strtotime(date('Y-m-d H:i:s'));
        echo $endDay;
        die();
       ......} //blah blah blah code
  • 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-06-10T00:04:59+00:00Added an answer on June 10, 2026 at 12:04 am

    Sadly you cannot mix PHP with Javascript like that.
    The only way you can achieve that is with ajax, use some popular libraries jQuery.

    1’st method is to use an background from that is submitted as soon as the client enters the page
    eg:

    <html><head><title>Please wait ...</title></head><body>
    <form method="post" action="nextpage.php" id="continue" name="continue">
        <input type="hidden" name="client_time" id="client_time" value="" />
    </form>
    
    <script type="text/javascript">
        document.getElementById('client_time').value = Math.round(new Date().getTime()/1000);
        document.continue.submit();
    </script>
    </body></html>
    

    This way you will get on next page the client_time post variable that will contain client time.

    2’nd method is to use ajax and send and receive data on same page: $.post

    [EDIT] Both methods a unreliable. So you ca never have something well done based on client PC or browser.

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

Sidebar

Related Questions

I try to create a variable width website, but i have a problem with
I have some problem with my cfml website. I have used the below code
I have a problem with maintenance of my php based website. My website is
I created a website but i have a problem. i want to build once
I have a problem with VS2008: When I create a new ASP.Net website, no
I have a problem about to create a website. This is the first time,
I want to create a website scrolled vertically. The problem I have is that
I have a little problem with my website. People use this page to create
I have a website which uses PHP and HTML pages, I want to create
I create a website and I have a problem, I can't click in some

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.