Days to 2016 Election
Here's a simple snippet example on showing how many days until the next election.
#!/usr/bin/php <?php date_default_timezone_set('America/New_York'); $dateDiff = mktime(0,0,0,11,8,2016) - mktime(); echo floor($dateDiff/60/60/24) . " days"; ?>
You could easily modify this to be any countdown that you want. (Christmas, Black Friday, Inauguration Day, Start of Summer)
Another Solution:
#!/usr/bin/php <?php date_default_timezone_set('America/New_York'); $datetime1 = new DateTime(); $datetime2 = new DateTime('2016-11-08'); $interval = $datetime1->diff($datetime2); echo $interval->format('%R%a days'); ?> |