php – js countdown timer


Came here because I couldn't find a good answer on Google. There, when requesting a js timer, the devil will break his leg! In general, help find or share your timer. We need a timer in JS so that the time is set manually: 30 minutes, 1 day, 1 week and 1 month. (The timer should not restart after a page refresh). After the time is up, you need to use ajax to send a post request to the specified route (laravel) that the timer has ended.


There are many countdown plugins for jQuery. For example allows you to do a countdown in any format – there are many examples .

The most popular countdown plugin is this one of examples too.

jQuery(function($) {
    until: new Date((new Date()).getFullYear() + 1, 1 - 1, 1),
    onExpiry: function(){ alert('Ура, новый год!!!'); /*Тут ваш POST запрос*/ },
    padZeroes: true
<script src=""></script>
<script src=""></script>
<script src=""></script>
<link href="">

<H2>Новый год скоро!</H2>
<span id="countdown-example"></span>
Scroll to Top