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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:46:30+00:00 2026-06-02T01:46:30+00:00

I have a countdown for my page to countdown from a certain date in

  • 0

I have a countdown for my page to countdown from a certain date in mysql database however I have no idea how to get the date from the database onto the javascript, I have echo’d the date onto the webpage just need to get it into the code and countdown from there now. Any help would be great. Thanks

This is my javascript

function calcage(secs, num1, num2) {
s = ((Math.floor(secs/num1))%num2).toString();
if (LeadingZero && s.length < 2)
s = "0" + s;
return "<b>" + s + "</b>";
}


function CountBack(secs) {
if (secs < 0) {
document.getElementById("cntdwn").innerHTML = FinishMessage;


return;
}
DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));

document.getElementById("cntdwn").innerHTML = DisplayStr;
if (CountActive)
setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}

function putspan(backcolor, forecolor) {
document.write("<span id='cntdwn' style='background-color:" + backcolor +
            "; color:" + forecolor + "'></span>");
}

if (typeof(BackColor)=="undefined")
BackColor = "white";
if (typeof(ForeColor)=="undefined")
ForeColor= "black";
if (typeof(TargetDate)=="undefined")
TargetDate = "12/31/2020 5:00 AM";
 if (typeof(DisplayFormat)=="undefined")
 DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
 if (typeof(CountActive)=="undefined")
 CountActive = true;
 if (typeof(FinishMessage)=="undefined")
 FinishMessage = "";
 if (typeof(CountStepper)!="number")
 CountStepper = -1;
 if (typeof(LeadingZero)=="undefined")
 LeadingZero = true;
 CountStepper = Math.ceil(CountStepper);
 if (CountStepper == 0)
 CountActive = false;
 var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
 putspan(BackColor, ForeColor);
 var dthen = new Date(TargetDate);
 var dnow = new Date();
 if(CountStepper>0)
 ddiff = new Date(dnow-dthen);
 else
 ddiff = new Date(dthen-dnow);
 gsecs = Math.floor(ddiff.valueOf()/1000);
 CountBack(gsecs);

THIS IS MY CODE IN THE HTML

<script language="JavaScript">
 TargetDate = "4/17/2012 23:41";
 BackColor = "white";
 ForeColor = "black";
 CountActive = true;
 CountStepper = -1;
 LeadingZero = true;
 DisplayFormat = "%%D%% Day, %%H%% Hour, %%M%% Minute, %%S%% Second ";
 FinishMessage = "Auction Ended";
 </script>
  • 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-02T01:46:32+00:00Added an answer on June 2, 2026 at 1:46 am

    your html file should be actually php an which you first call your query:

    $sql = "SELECT enddate FROM property WHERE propertyID = '1'"; 
    $queryresult = mysql_query($sql) or die (mysql_error()); 
    while ($row = mysql_fetch_assoc($queryresult))
    { $enddate=$row['enddate']; }
    

    then you format your date as:

    $enddate = date("j/m/Y H:i",strtotime($enddate));
    

    then after php code you have your html code and you print date as:

    <script language="JavaScript">
     TargetDate = "<?php echo $enddate; ?>";
     BackColor = "white";
     ForeColor = "black";
     CountActive = true;
     CountStepper = -1;
     LeadingZero = true;
     DisplayFormat = "%%D%% Day, %%H%% Hour, %%M%% Minute, %%S%% Second ";
     FinishMessage = "Auction Ended";
     </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many countdown timers on the page. Timers countdown remaining time from current
I have a countdown timer in javascript that is called by a code behind
I have a webpage which is basically a countdown timer. The initial value of
I have a page where i have a countdown and flow player. I have
I have an MVC application that I need to countdown a certain number of
I have a jquery timer on my page that counts down from 10 to
In my android project, I have a countdown that randomizes a boolean for an
I have a client who needs somebody to develop a countdown widget for their
I have created an application.in the app i start a countdown timer and save
I have the following script: Timer=0; function countdown(auctionid){ var auctions; var divs; Timer=Timer+1; if((Timer%10==0)||(Timer==1)){

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.