OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

whats wrong with my timer code? im making this website for my gf but im not sure whats wrong this is code? t [closed]

  • Thread starter Thread starter youussh
  • Start date Start date
Y

youussh

Guest
Code:
document.addEventListener('DOMContentLoaded', function() {
    // Timer code
    function updateTimer() {
        const startDate = new Date("2024-06-05T17:00:00").getTime();
        const now = new Date().getTime();
        const distance = now - startDate;

        const years = Math.floor(distance / (1000 * 60 * 60 * 24 * 365));
        const days = Math.floor((distance % (1000 * 60 * 60 * 24 * 365)) / (1000 * 60 * 60 * 24));
        const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
        const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
        const seconds = Math.floor((distance % (1000 * 60)) / 1000);

        document.getElementById("timer").innerHTML = years + " years " + days + " days " + hours + " hours " + minutes + " minutes " + seconds;
    }
    setInterval(updateTimer, 1000);


please help

i made this code to get like as a timer for my relationship with my girlfriend. but nothing appeared on the website.

<pre><code>document.addEventListener('DOMContentLoaded', function() {
// Timer code
function updateTimer() {
const startDate = new Date("2024-06-05T17:00:00").getTime();
const now = new Date().getTime();
const distance = now - startDate;

const years = Math.floor(distance / (1000 * 60 * 60 * 24 * 365));
const days = Math.floor((distance % (1000 * 60 * 60 * 24 * 365)) / (1000 * 60 * 60 * 24));
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((distance % (1000 * 60)) / 1000);

document.getElementById("timer").innerHTML = years + " years " + days + " days " + hours + " hours " + minutes + " minutes " + seconds;
}
setInterval(updateTimer, 1000);

</code></pre>
<hr />
<p>please help</p>
<p>i made this code to get like as a timer for my relationship with my girlfriend. but nothing appeared on the website.</p>
 

Latest posts

Top