(function ($) {
//**********************************
// Se le pasa un número de uno o más digitos.
// Si el número tiene un único dígito, lo devuelve
// con dos dítigos añadiéndole un 0 por delante.
//**********************************
function RellenarCeros(t) {
t = t + "";
if (t.length == 1)
return "0" + t;
else
return t;
};
// ******************************************
// Función que convierte una fecha
// de formato "05/11/2015 20:00:00"
// en un objeto fecha javascript
//********************************************
function ParseDate(strDate) {
var res = strDate.split("/", 3);
var dia = res[0];
var mes = res[1];
var stranyo = res[2].split(" ", 2);
var anyo = stranyo[0];
var strTiempo = stranyo[1].split(":", 3);
var hh = strTiempo[0];
var mm = strTiempo[1];
var ss = strTiempo[2];
// Los meses empiezan en el 0 es enero
mes = mes - 1;
return new Date(anyo, mes, dia, hh, mm, ss);
};
// Método contador
$.fn.countdown = function (valorInicial) {
// variables
var time = new Date();
var interv;
var divObj;
// Establecemos una constante para el tiempo de actualización.
var TiempoActualizacion = 1000;
// Estamos inicializando el timer
// si viene informado, lo inicializamos
if (valorInicial !== undefined) {
time = new Date(valorInicial);
}
// Función para mostrar el tiempo
displayTime = function () {
this.text(RellenarCeros(time.getHours() - 1) + ":" + RellenarCeros(time.getMinutes()) + ":" + RellenarCeros(time.getSeconds()));
};
// Función para empezar
start = function () {
this.interv = setInterval(function (obj) {
time = new Date(time - TiempoActualizacion);
if (time <= 0) {
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.