QA Graphic

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');
?>

2016datetime

 

About

I find TextExpander, by Smile on My Mac, to be an awesome productivity tool. This past winter, I posted some cool snippets that demonstrate the power of the application. Occasionally, I will post some new snippets that I think will be useful in anyone's TextExpander library.

Schedule

Friday 21 Macintosh
Saturday 22 Internet Tools
Sunday 23 Misc
Monday 24 Media
Tuesday 25 QA
Wednesday 26 Pytest
Thursday 27 PlayWright