SHARE
TWEET

Comparando datas em PHP

a guest Jul 16th, 2013 190 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $dataAtual = new DateTime(); // data atual
  2.  
  3. $dataExpira = new DateTime("2012-10-05"); // data de expiração do anúncio
  4.  
  5. // data atual é maior que a data de expiração
  6. if ($dataAtual > $dataExpira){ // true
  7.   echo  "Seu anuncio expirou! Deseja renovar?";
  8. } else { // false
  9.   echo "Anuncio ativo";
  10. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top