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
Why and where do we use htaccess?
What distinguishes php from something like client side java script?
Write a program to display reverse of any number?
Write a program using while loop?
What is restful api?
What difference between require() and require_once()?
Explain what is the use of "echo" in php?
What is the use of mvc in php?
What is difference between core php and framework?
What is the difference between == and === operator in PHP?
Can you define an array argument as a reference type?
What is the importance of "action" attribute in a html form?
Can we use get instead of post?
Why do we use inheritance in php?
Name and explain five of the PHP error constants?