Last active
April 19, 2016 00:00
-
-
Save knoonrx/2b800b752a9ba01f7c8af6d663cd4069 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 | |
$date_expire = '2016-04-16'; | |
$date = new DateTime($date_expire); | |
$now = new DateTime(); | |
//echo $date->diff($now)->format("%d days, %h hours and %i minuts"); | |
//$time = $date->diff($now)->format("%d"); | |
//echo $time; | |
if ( $date->diff($now)->format("%d") >= 2) // if date in days is greather than 2, do something | |
{ | |
echo "É maior que dois!!"; | |
} | |
echo "\n"; | |
// agora com um pouco mais de precisão | |
$date_expire = '2016-04-16 23:58:00'; | |
$date = new DateTime($date_expire); | |
$now = new DateTime(); | |
//echo $date->diff($now)->format("%d days, %h hours and %i minuts"); | |
if ( $date->diff($now)->format("%d.%h") >= 2) | |
{ | |
echo "É maior que dois!!"; | |
} else { | |
echo "não é maior"; | |
} | |
echo "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment