Regressive time catching date of another variant

Asked

Viewed 49 times

-3

I would like to obtain a variant that, I use in my shop..

For example, I can add a variation of clothing colors, in this case, it would be the time variant and set a date, such as "August 29, 2021 17:40:00" thus being one for each product at the following date and present it on the display of the given product together with the exact time that is missing. This is possible?

I am beginner, so I am seeing many tutorials, if anyone can share the knowledge I will be grateful!

  • Follow my code below:

// Colocar a data final do timer
var countDownDate = new Date("august 29, 2021 17:40:00").getTime();

// Atualiza a contagem a cada 1 segundo
var x = setInterval(function() {

   // Get today's date and time
   var now = new Date().getTime();

   // Cálculo para saber quanto falta para o timer
   var distance = countDownDate - now;

   // Calculadora dias, horas, minutos e segundos
   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);

   // Cria o resultando em um elemento chamado id="timer"

   document.getElementById("timer").innerHTML = days + " Dias " + hours + "h " +
      minutes + "m " + seconds + "s ";

   // Quando terminar a contagem, apresenta Pronta Entrega 
   if (distance < 0) {
      clearInterval(x);
      document.getElementById("timer").innerHTML = "PRONTA ENTREGA";
   }
}, 1000);
    <!DOCTYPE HTML>
    <html>

    <head>
       <meta name="viewport" content="width=device-width, initial-scale=1">
       <style>
          p {
             text-align: center;
             font-size: 25px;
             margin-top: 10px;
             color: red
          }
       </style>
       <center>
          <h2>
             <color:red;>Trade Lock</color:red;>
          </h2>
       </center>
    </head>

    <body>

       <p id="timer"></p>
      
    </body>

    </html>

I’d like to pull that information into the timer to get the date, you know?Exemplo posso adicionar na loja essa variável

Here is another image below it would be possible to pull from this element this information? Seria possível?

  • Friend, I edited your question based on what I understood, because she is nothing CLEAR suggest edit it again to meet the criteria of a [Re].

  • I edited again and put images to be clearer to understand.

  • No, images like code or error messages, examples of the question, are not well seen by the community, see Manual on how NOT to ask questions

  • can delete then, I will search in another forum, because the code has no error, I just want help to be able to pull the date of another variant to not have to fill, because each product has a different time. But if it is not well seen, or I can not express myself well enough delete the topic kindly, because in my view it is clear. Thank you anyway.

  • The problem is not deleting your question, it is that in order to help you, it needs to meet the criteria of a [Mre], that is, so that we can analyze as a whole, understand the ultimate goal and bring you a good result. What’s the good of me answering your question that doesn’t solve or do exactly what you want. Don’t get me wrong, but here we are not one FORUM we are a community of QUESTIONS and ANSWERS

  • View, review, analyze and publish! Before you even ask, use a notepad or something. I saw here that your question is very specific, I believe you already tried to seek the solution/ answer but did not find in fact! do this! See how to ask a good question? I believe I can help you greatly!

  • Let’s review? From what I understand you want to add a final date to the right products? Suppose the final date is, *"05/September/2021 at 17:00" and then a regressive time from the current date (in this case today) until the final date is this? However, it will display how many days, hours, minutes and seconds remain before arriving on September 5th at 17:00

  • Exactly, but I want to pull this information from the site itself, is that I do not have access to all store code, otherwise I could add an input in the product registration to fill the date and thus generating the timer for each product, but the cloud platform does not allow this, so I wanted a form of it to get the information from the "timer" that I made the variable as well as the color of a shirt, and put that information in the code to show the days hours etc.. As I said I am beginner in this so I have difficulty and may be using the name of the wrong term as well. I apologize for this.

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.