Created
February 15, 2011 16:52
-
-
Save lpirola/827790 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* INI: TIME REMAINS */ | |
function restTime( YY , MM , DD , HH , MI, i ) { | |
var | |
SS = 00, | |
h = new Date(), | |
ff = new Date( YY , MM-1 , DD , HH , MI , SS ), | |
ss = parseInt( (ff - h) / 1000 ), | |
mm = parseInt( ss / 60 ), | |
hh = parseInt( mm / 60 ), | |
dd = parseInt( hh / 24 ), | |
ss = ss - ( mm * 60 ), | |
mm = mm - ( hh * 60 ), | |
hh = hh - ( dd * 24 ); | |
var remainingTime = []; | |
remainingTime.push( ( dd && dd > 1 ) ? '<strong>' + dd + '</strong> dias, ' : ( dd == 1 ? '<strong>1</strong> dia, ' : '' ) ); | |
remainingTime.push( ( toString(hh).length ) ? '<strong>' + hh + '</strong> horas e ' : '' ); | |
remainingTime.push( ( toString(mm).length ) ? '<strong>' + mm + '</strong> minutos e ' : '' ); | |
remainingTime.push( '<strong>' + ss + '</strong> segundos' ); | |
if( dd + hh + mm + ss > 0 ){ | |
$( '#restTime' + i ).html( 'Oferta encerra em ' + remainingTime.join('') ); | |
setTimeout(function(){restTime( YY , MM , DD , HH , MI , i )},1000); | |
}else{ | |
$( '#restTime' + i ).html( '<span class="noOffer">Esta Oferta não está mais Disponível</span>' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment