Foros del Web » Programando para Internet » Jquery »

Colocar fecha en cuenta regresiva

Estas en el tema de Colocar fecha en cuenta regresiva en el foro de Jquery en Foros del Web. Hola a todos, baje un codigo para hacer una cuenta regresiva y no se como escribir la fecha limite. Tengo conocimientos casi nulos de JavaScript. ...
  #1 (permalink)  
Antiguo 01/07/2015, 06:41
 
Fecha de Ingreso: enero-2010
Mensajes: 400
Antigüedad: 14 años, 3 meses
Puntos: 6
Colocar fecha en cuenta regresiva

Hola a todos, baje un codigo para hacer una cuenta regresiva y no se como escribir la fecha limite. Tengo conocimientos casi nulos de JavaScript. Espero que me lo puedan solucionar facilmente. Gracias

Código Javascript:
Ver original
  1. (function($) {
  2.     $.fn.countdown = function(options, callback) {
  3.  
  4.         //custom 'this' selector
  5.         thisEl = $(this);
  6.  
  7.         //array of custom settings
  8.         var settings = {
  9.             'date': null,
  10.             'format': null
  11.         };
  12.  
  13.         //append the settings array to options
  14.         if(options) {
  15.             $.extend(settings, options);
  16.         }
  17.        
  18.         //main countdown function
  19.         function countdown_proc() {
  20.            
  21.             eventDate = Date.parse(settings['date']) / 1000;
  22.             currentDate = Math.floor($.now() / 1000);
  23.            
  24.             if(eventDate <= currentDate) {
  25.                 callback.call(this);
  26.                 clearInterval(interval);
  27.             }
  28.            
  29.             seconds = eventDate - currentDate;
  30.            
  31.             days = Math.floor(seconds / (60 * 60 * 24)); //calculate the number of days
  32.             seconds -= days * 60 * 60 * 24; //update the seconds variable with no. of days removed
  33.            
  34.             hours = Math.floor(seconds / (60 * 60));
  35.             seconds -= hours * 60 * 60; //update the seconds variable with no. of hours removed
  36.            
  37.             minutes = Math.floor(seconds / 60);
  38.             seconds -= minutes * 60; //update the seconds variable with no. of minutes removed
  39.            
  40.             //conditional Ss
  41.             if (days == 1) { thisEl.find(".timeRefDays").text("day"); } else { thisEl.find(".timeRefDays").text("days"); }
  42.             if (hours == 1) { thisEl.find(".timeRefHours").text("hour"); } else { thisEl.find(".timeRefHours").text("hours"); }
  43.             if (minutes == 1) { thisEl.find(".timeRefMinutes").text("minute"); } else { thisEl.find(".timeRefMinutes").text("minutes"); }
  44.             if (seconds == 1) { thisEl.find(".timeRefSeconds").text("second"); } else { thisEl.find(".timeRefSeconds").text("seconds"); }
  45.            
  46.             //logic for the two_digits ON setting
  47.             if(settings['format'] == "on") {
  48.                 days = (String(days).length >= 2) ? days : "0" + days;
  49.                 hours = (String(hours).length >= 2) ? hours : "0" + hours;
  50.                 minutes = (String(minutes).length >= 2) ? minutes : "0" + minutes;
  51.                 seconds = (String(seconds).length >= 2) ? seconds : "0" + seconds;
  52.             }
  53.            
  54.             //update the countdown's html values.
  55.             if(!isNaN(eventDate)) {
  56.                 thisEl.find(".days").text(days);
  57.                 thisEl.find(".hours").text(hours);
  58.                 thisEl.find(".minutes").text(minutes);
  59.                 thisEl.find(".seconds").text(seconds);
  60.             } else {
  61.                 alert("Invalid date. Here's an example: 12 Tuesday 2020 17:30:00");
  62.                 clearInterval(interval);
  63.             }
  64.         }
  65.        
  66.         //run the function
  67.         countdown_proc();
  68.        
  69.         //loop the function
  70.         interval = setInterval(countdown_proc, 1000);
  71.        
  72.     }
  73. }) (jQuery);

Etiquetas: fecha, form, html, javascript, regresiva, select
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:04.