lib/blobfolio/common/data.php
public static function datediff($date1, $date2) {
		ref\sanitize::date($date1);
		ref\sanitize::date($date2);

		// Same or bad dates.
		if (
			! \is_string($date1) ||
			! \is_string($date2) ||
			($date1 === $date2) ||
			('0000-00-00' === $date1) ||
			('0000-00-00' === $date2)
		) {
			return 0;
		}

		// Prefer DateTime.
		if (\class_exists('DateTime')) {
			$date1 = new \DateTime($date1);
			$date2 = new \DateTime($date2);
			$diff = $date1->diff($date2);

			return \abs($diff->days);
		}

		// Fallback to counting seconds.
		$date1 = \strtotime($date1);
		$date2 = \strtotime($date2);
		return \ceil(\abs($date2 - $date1) / 60 / 60 / 24);
	}
public static function datediff($date1, $date2) {
		ref\sanitize::date($date1);
		ref\sanitize::date($date2);

		// Same or bad dates.
		if (
			! \is_string($date1) ||
			! \is_string($date2) ||
			($date1 === $date2) ||
			('0000-00-00' === $date1) ||
			('0000-00-00' === $date2)
		) {
			return 0;
		}

		// Prefer DateTime.
		if (\class_exists('DateTime')) {
			$date1 = new \DateTime($date1);
			$date2 = new \DateTime($date2);
			$diff = $date1->diff($date2);

			return \abs($diff->days);
		}

		// Fallback to counting seconds.
		$date1 = \strtotime($date1);
		$date2 = \strtotime($date2);
		return \ceil(\abs($date2 - $date1) / 60 / 60 / 24);
	}
public static function datediff ( $ date1 , $ date2 ) { ref \ sanitize :: date ( $ date1 ) ; ref \ sanitize :: date ( $ date2 ) ; // Same or bad dates. if ( ! \ is_string ( $ date1 ) || ! \ is_string ( $ date2 ) || ( $ date1 === $ date2 ) || ( '0000-00-00' === $ date1 ) || ( '0000-00-00' === $ date2 ) ) { return 0 ; } // Prefer DateTime. if ( \ class_exists ( 'DateTime' ) ) { $ date1 = new \ DateTime ( $ date1 ) ; $ date2 = new \ DateTime ( $ date2 ) ; $ diff = $ date1 -> diff ( $ date2 ) ; return \ abs ( $ diff -> days ) ; } // Fallback to counting seconds. $ date1 = \ strtotime ( $ date1 ) ; $ date2 = \ strtotime ( $ date2 ) ; return \ ceil ( \ abs ( $ date2 - $ date1 ) / 60 / 60 / 24 ) ; }
Days Between Dates

@param string $date1 Date.
@param string $date2 Date.
@return int Difference in Days.
Days Between Dates