# Count Down Timer Function 

**URL:** <https://forum.wixstudio.com/t/count-down-timer-function/17603>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [July 2, 2019, 1:35pm UTC](https://forum.wixstudio.com/t/count-down-timer-function/17603 "2019-07-02T13:35:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonadams](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@simonadams](https://forum.wixstudio.com/u/simonadams)\
**Post date:** [July 2, 2019, 1:35pm UTC](https://forum.wixstudio.com/t/count-down-timer-function/17603/1 "2019-07-02T13:35:00Z")

</div>

```javascript
For All those of you that need a Countdown Timer Function: 

function timer() {
 var epoch = Math.round(new Date().getTime() / 1000.0);
 var countDown = 1200 - (epoch % 1200);
 let minutes = (countDown / 60) | 0;
 let seconds = (countDown % 60) | 0;
    minutes = minutes < 10 ? "0" + minutes : minutes;
    seconds = seconds < 10 ? "0" + seconds : seconds;
 if (epoch % 1200 === 0) updateOtp(); // place any other function here
    $w('#textUpdatingIn2').text = minutes + ":" + seconds;
    $w('#updatingIn2').text = minutes + ":" + seconds;
}

```

This is a very basic Timer and where it says “updateOtp” you can place any function you would like here to take place once your timer has counted down to 0. This timer is set to 1200ms (2 Minutes) but can easily be adjusted. The Countdown is show in a text element here “textUpdatingIn2” and “updatingIn2” I hope this will help someone if it does let me know.

---

<div class="post-metadata">

**Author:** ![givemeawhisky](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/givemeawhisky/32/5383_2.png) [@givemeawhisky](https://forum.wixstudio.com/u/givemeawhisky)\
**Post date:** [July 2, 2019, 1:55pm UTC](https://forum.wixstudio.com/t/count-down-timer-function/17603/2 "2019-07-02T13:55:18Z")

</div>

Nice, however @yisrael-wix has already done one for the tutorial section as shown here.  
[https://www.wix.com/corvid/forum/community-discussion/example-countdown](https://www.wix.com/corvid/forum/community-discussion/example-countdown)  
[https://www.velobrewmaster.com/Examples/Countdown](https://www.velobrewmaster.com/Examples/Countdown)  
[https://www.velobrewmaster.com/Examples/Count-Down-Up](https://www.velobrewmaster.com/Examples/Count-Down-Up)

Which can be found on his own page here.  
[https://www.velobrewmaster.com/examples](https://www.velobrewmaster.com/examples)

---

<div class="post-metadata">

**Author:** ![simonadams](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@simonadams](https://forum.wixstudio.com/u/simonadams)\
**Post date:** [July 2, 2019, 2:03pm UTC](https://forum.wixstudio.com/t/count-down-timer-function/17603/3 "2019-07-02T14:03:34Z")

</div>

Thats Great, I have just had a look, the examples shown I believe do not show how to fire a function, this was just a very basic one that gives the ability for a function to be done after X time.

---

<div class="post-metadata">

**Author:** ![hyphen1961](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/hyphen1961/32/27946_2.png) [@hyphen1961](https://forum.wixstudio.com/u/hyphen1961)\
**Post date:** [May 13, 2021, 12:26am UTC](https://forum.wixstudio.com/t/count-down-timer-function/17603/4 "2021-05-13T00:26:46Z")

</div>

Great this helps me a lot

---

<div class="post-metadata">

**Author:** ![david12252006](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/david12252006/32/27969_2.png) [@david12252006](https://forum.wixstudio.com/u/david12252006)\
**Post date:** [September 5, 2021, 8:54pm UTC](https://forum.wixstudio.com/t/count-down-timer-function/17603/5 "2021-09-05T20:54:33Z")

</div>

Is there any way to get this to connect to a progress bar. Something like 87% of the way to Halloween with a progress bar visual

---

<div class="post-metadata">

**Author:** ![simonadams](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@simonadams](https://forum.wixstudio.com/u/simonadams)\
**Post date:** [September 6, 2021, 12:00pm UTC](https://forum.wixstudio.com/t/count-down-timer-function/17603/6 "2021-09-06T12:00:58Z")

</div>

I am sure there will be a way to do so, if you create a function to update the progress bar figure every second, minute or hour or whatever interval you choose to utilise.
