Last active
March 10, 2017 20:02
-
-
Save mostafasoufi/6e7f2ec1e62d4ac2e13df60a202d51ac to your computer and use it in GitHub Desktop.
Get Number of days between two dates
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 | |
if (!function_exists('get_days_number')) { | |
/** | |
* Get Number of days between tho dates | |
* | |
* @param string $first_date First date | |
* @param string $second_date Second date | |
* @return float | |
*/ | |
function get_days_number($first_date, $second_date) | |
{ | |
// Return the number of days between the two dates: | |
return round(abs(strtotime($first_date) - strtotime($second_date)) / 86400); | |
} | |
} | |
echo get_days_number(date('Y-m-d'), '2016-10-15'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment