<?php
/**
* Calculate the number of days between two dates.
* The order of the dates is irrelevant.
* @param string $date1 The first date
* @param string $date2 The second date
* @return int
* @author Sunny Walker <www.miraclesalad.com>
*/
function daysDiff($date1, $date2) {
return (max(strtotime($date1), strtotime($date2))-min(strtotime($date1), strtotime($date2)))/86400;
} //daysDiff()
?>
Calculate the number of days between two dates. The order of the dates is irrelevant and any date format supported by http://php.net/strtotime should work.
3 Responses
Thank you ;)
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.