Last active
August 29, 2015 14:06
-
-
Save abacaj/ce27e02b77e640b7ec75 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
/* | |
this function will take in a due date and determine the remaining days until something is due from the current date. | |
*/ | |
public function calculateDate($due_date) | |
{ | |
$future = strtotime($due_date); | |
$now = time(); | |
$timeleft = $future-$now; | |
$daysleft = round((($timeleft/24)/60)/60); | |
return $daysleft; | |
} | |
/* | |
example usage: | |
$duedate = '2014-12-12' | |
$remainingdays = $this->calculateDate($duedate); | |
echo "days remaining are:" . $remainingdays; // output: "days remaining are: 99 days" - from 2014-09-03 to 2014-12-12. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment