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
What is $_ get?
Can we extend multiple classes in php?
How long is a php session valid?
What are the advantages and disadvantages of cascade style sheets?
What are the data types in php?
How stop the execution of a php scrip?
Why php is sometimes called as embedded scripting language?
What is a php web application?
What is the Pipe Symbol represented?
How does api connect to database?
How to redirect a page in php?
Why do we use session?
How do you find the length of a string in php?
What is data abstraction in php?
Is null or empty c#?