Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How can we know the number of days between two given dates
using PHP?
How can we know the number of days between two given dates
using MySQL?

Answer Posted / jitendra jhariya and sandeep s

function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1],
$date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1],
$date_parts2[2]);
return $end_date - $start_date;
}Now let us see how we use this function:$date1="07/11/2003";
$date2="09/04/2004";print "If we minus " . $date1 . " from "
. $date2 . " we get " . dateDiff("/", $date2, $date1) .
".";which generates If we minus 07/11/2003 from 09/04/2004
we get 421.

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does the identity operator === compare two values?

1070


Is there an easy way to delete an element from a php array?

876


Explain me what is x+ mode in fopen() used for?

955


What is form validation in php?

966


What is full form of php? Who is the father or inventor of php?

947


What does mvc stand for and what does each component do?

985


Where php basically used?

942


What is difference between readonly and constant?

939


What is the difference between php and javascript?

1108


What's the difference between accessing a class method via -> and via ::?

1035


How to access a Static Member of a Class in PHP?

970


Why would we use === instead of ==?

8788


What is singleton class in php?

938


What is the use of header in php?

923


How to get the directory name out of a file path name?

911