Neu Sonderpreis Countdown timer

mnause

Aktives Mitglied
19. Juli 2016
81
14
Essen
Firma
NAAM Distribution GmbH
Hallo ich wollte in der item_list.tpl und der Item_box.tpl folgendes implementieren aber irgendwo ist der Wurm drin hat jemand einen Tip für mich ?


Code:
{if {$smarty.now|date_format:"%Y%m%d"} < {$Artikel->Preise->SonderpreisBis_de|date_format:"%Y%m%d+1"}}
 
    <div align="center">Das Angebot gilt nur noch</div>
  <div><p id="demo"></p></div>

<script>
// Set the date we're counting down to

var countDownDate = new Date({$Artikel->Preise->SonderpreisBis_en|date_format:"%Y-%m-%d 23:59:59"});

// Update the count down every 1 second
var x = setInterval(function() {

  // Get today's date and time
  var now = new Date().getTime();
   
  // Find the distance between now and the count down date
  var distance = countDownDate - now;
   
  // Time calculations for days, hours, minutes and seconds
  var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  var seconds = Math.floor((distance % (1000 * 60)) / 1000);
   
  // Output the result in an element with id="demo"
  document.getElementById("demo").innerHTML = days + " Tage " + hours + " Stunden "
  + minutes + " Minuten";
   
  // If the count down is over, write some text
  if (distance < 0) {
    clearInterval(x);
    document.getElementById("demo").innerHTML = "EXPIRED";
  }
}, 1000);
</script>
            {/if}
 

mnause

Aktives Mitglied
19. Juli 2016
81
14
Essen
Firma
NAAM Distribution GmbH
Code:
<div>
 Das Angebot gilt nur noch <span id="demo"></span>
</div>
<script>
// Set the date we're counting down to

var countDownDate = new Date("{$Artikel->Preise->SonderpreisBis_en|date_format:"%Y-%m-%d 23:59:59"}");

// Update the count down every 1 second
var x = setInterval(function() {

  // Get today's date and time
  var now = new Date().getTime();
 
  // Find the distance between now and the count down date
  var distance = countDownDate - now;
 
  // Time calculations for days, hours, minutes and seconds
  var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  var seconds = Math.floor((distance % (1000 * 60)) / 1000);
 
  // Output the result in an element with id="demo"
  document.getElementById("demo").innerHTML = days + " Tage " + hours + " Stunden "
  + minutes + " Minuten";
 
  // If the count down is over, write some text
  if (distance < 0) {
    clearInterval(x);
    document.getElementById("demo").innerHTML = "EXPIRED";
  }
}, 1000);
</script>

Den Fehler habe ich gefunden allerdings zeigt er es nur im ersten Artikel an !!! und er rechnet über eine Woche drauf
 
Zuletzt bearbeitet: