fork(2) download
  1. <?php
  2. date_default_timezone_set('America/Sao_Paulo');
  3.  
  4. function IsExpireData($data){
  5. $data = explode(" ", $data);
  6. list($d, $m, $y) = explode('/', $data[0]);
  7. list($g, $i) = explode(':', $data[1]);
  8. $dat0 = new DateTime(date("Y-m-d G:i:s", mktime($g, $i, 0, $m, $d, $y)));
  9. $dat1 = new DateTime(date("Y-m-d G:i:s"));
  10.  
  11. $ret = '';
  12. if ($dat0 == $dat1) {
  13. $ret = 0;
  14. } else {
  15. if ($dat1 < $dat0){
  16. $ret = 1;
  17. } else {
  18. if ($dat1 > $dat0){
  19. $ret = -1;
  20. }
  21. }
  22. }
  23. return $ret;
  24. }
  25.  
  26. $d = IsExpireData("09/06/2014 14:00");
  27. if ($d == 0 || $d == -1){
  28. echo 'Expirado';
  29. } else {
  30. echo 'Ainda não expirou';
  31. }
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
    Expirado