Last active
June 18, 2016 21:50
-
-
Save rafaelaugustos/acf76a2c7d42f9204634f9da392375e8 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
<?php | |
$dia_hora_atual = strtotime(date("Y-m-d H:i:s")); | |
$dia_hora_evento = strtotime(date("2016-12-15 08:00:00")); | |
$diferenca = $dia_hora_evento - $dia_hora_atual; | |
$dias = intval($diferenca / 86400); | |
$marcador = $diferenca % 86400; | |
$hora = intval($marcador / 3600); | |
$marcador = $marcador % 3600; | |
$minuto = intval($marcador / 60); | |
$segundos = $marcador % 60; | |
echo "$dias dia(s) $hora hora(s) $minuto minuto(s) $segundos segundo(s)"; | |
?> |
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
$(function(){ | |
// Requisicao AJAX | |
var requisicao = function(){ | |
$.ajax({ | |
url: "contador.php" | |
}).done(function(resultado){ | |
// Exibe o resultado no elemento com ID contador | |
$("#contador").html(resultado); | |
}); | |
}; | |
// Executa a requisicao com intervalo de 100ms | |
setInterval(requisicao, 100); | |
}); |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
</head> | |
<body> | |
<p>Faltam <span id="contador"></span> para o fim do mundo!</p> | |
<script src="jquery.js"></script> | |
<script src="funcoes.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment