Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
How to convert jquery countdown function to countup function?

I am working on a portal which is basically using a jquery plugin called countdown i.e. https://github.com/hilios/jQuery.countdown

The piece of code is:

$(document).ready(function(){

$("#countdown").countdown("2022/06/25 10:00:00", function(event) {
  var $this = $(this).html(event.strftime(''
     + '%-D Days'
});

How can I make it in reverse? Instead of counting it down to the date, is it possible to count from the date? and display how many days it's been.

Any help would be highly appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As you have not posted the complete countdown function, I am assuming the one from the link you have pasted (https://github.com/hilios/jQuery.countdown)

If you carefully look at the countdown function here https://github.com/hilios/jQuery.countdown/blob/223789964fd1854e04a60d6eba3fd22d20b1f34f/src/countdown.js#L269 you can easily modify it.

I have had similar requirements in the past and writing my own function was easier than modifying the existing one.

For example, the function:

$(document).ready(function () {
    $(function () {
      var calcNewYear = setInterval(function () {
        var date_started = new Date("2022/06/25"); // your date to count from
        var date_now = new Date(); // current timestamp 
        var one_day = 1000 * 60 * 60 * 24;
        var days = Math.floor((date_now - (date_started)) / one_day); // days from the date
        }
    }
}

Then include it wherever it is needed:

("#countdown").html(days + ' Days');
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda