Skip to content

Instantly share code, notes, and snippets.

@mostafasoufi
Last active March 10, 2017 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mostafasoufi/6e7f2ec1e62d4ac2e13df60a202d51ac to your computer and use it in GitHub Desktop.
Save mostafasoufi/6e7f2ec1e62d4ac2e13df60a202d51ac to your computer and use it in GitHub Desktop.
Get Number of days between two dates
<?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