<?
# strtotime(YYYY-MM-DD)

# $fonte = $_GET['d']; // Formato: DD/MM/YYYY
$fonte = "05/12/2007";

function valida($fonte){
// Valida se a data segue o formato correto no padr�o brasileiro
$ex = explode('/',$fonte);
if(substr_count($fonte,'/') != 2){ return false; }
if(strlen($fonte) != 10){ return false; }
if(count($ex) != 3 ) { return false; }
if(!is_numeric($ex[0]) and !is_numeric($ex[1]) and !is_numeric($ex[2])){ return false; }
if($ex[0] > 31) { return false; }
if($ex[1] > 12) { return false; }
return TRUE;
}



if(empty($fonte)){ echo "\$fonte est� sem valor";exit; }
if(!valida($fonte)){ echo "Data inv�lida";exit; }

$nome = "terminar o ano letivo";
$atual = strtotime("20".date(y)."-".date(m)."-".date(d)."");
$evento = strtotime("".substr($fonte,6,8)."-".substr($fonte,3,2)."-".substr($fonte,0,2)."");
$diferenca = ($evento - $atual) /60/60/24;

echo "Faltam ".$diferenca." dias para <b>".$nome."</b> !";

# Resultado do strtotime() � dado em segundos
# Divide-se por 60 para mostrar em minutos
# Divide-se por 60 novamente para mostrar em horas
# Divide-se por 24 para mostrar em dias

?>