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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:20:39+00:00 2026-06-04T10:20:39+00:00

I have built a voucher website, where each voucher has a countdown timer. When

  • 0

I have built a voucher website, where each voucher has a countdown timer. When you view a voucher the countdown works fine, however…
I also have a summary page with multiple vouchers (using a repeat region on the recordset)… when I apply the script to each of the vouchers the script doesn’t work.

The HMTL:

      <h3 class="remaining"><?php echo $row_rs_dealItem['dateend']; ?> remaining</h3>

The JAVASCRIPT external file:

$(document).ready(function(){
$('.remaining').each(function(){
    var expiry_date = Date.createFromMysql($(this).html());
    var current_date = new Date();
    console.log(expiry_date.getTime() );
    console.log(current_date.getTime());
    if (expiry_date.getTime() >  current_date.getTime()) {
        var time_diff = Math.floor((expiry_date.getTime() - current_date.getTime()) / (1000*60*60));
        console.log(expiry_date.getTime() - current_date.getTime());
        console.log(time_diff);
        days_diff = Math.floor(time_diff / 24);
        hours_diff = time_diff % 24;

        $(this).html(days_diff + ' days ' + hours_diff + ' hours');
    }
    else{
        $(this).html('expired');
    }
});
}); 

 Date.createFromMysql = function(mysql_string)
{ 
 if(typeof mysql_string === 'string')
{
   var t = mysql_string.split(/[- :]/);

  //when t[3], t[4] and t[5] are missing they defaults to zero
  return new Date(t[0], t[1] - 1, t[2], t[3] || 0, t[4] || 0, t[5] || 0);          
}

return null;   
}

The JAVASCRIPT inline:

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="scripts/script.js"></script>
<script type="text/javascript">
    var reference       = '<?php echo $row_rs_dealItem['reference']; ?>';
    var today           = Date.createFromMysql('<?php echo date('Y-m-d h:i:s'); ?>');
    var contractstarts  = <?php echo ($row_rs_dealItem['datestart'] == '0000-00-00') ? '""' : 'Date.createFromMysql("' . $row_rs_dealItem['datestart'] . '")'; ?>;
    var contractexpires = <?php echo ($row_rs_dealItem['dateend'] == '0000-00-00') ? '""' : 'Date.createFromMysql("' . $row_rs_dealItem['dateend'] . '")'; ?>;
</script>

I hope this is enough data for you.

thanks

  • 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-04T10:20:41+00:00Added an answer on June 4, 2026 at 10:20 am

    I realised that I had effectively copied the code from one page to another and the record sets had different names 🙁

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

Sidebar

Related Questions

I have built a website(asp.net): http://avior-ins.co.il/ I can view the site on my computer(I
I have built a site in wordpress and the home page is really screwed
I have built a MVC website on IIS6. I used the built-in ASP.NET Security
I have built a website and when my users load up http://info.salemgolfclub.org/Account/Logon the username
I have built a one page web application that manipulates a set of data:
I have built a web page which contains a Crystal Report built using the
I have built a User Control library that has a reference to a WCF
I have built a dom object Engine that has private/public fields/methods that I have
I have built an application with a tree view showing the file structure of
I have built a console application that works okay when it references a .exe

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.