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 / vinay sachan
<?PHP
// different between two dates by date_diff() function:-
$datetime1 = date_create('2010-01-01');
$datetime2 = date_create('2012-1-15');
$interval = date_diff($datetime1, $datetime2);
echo $interval->format('%a days')."<br>";
//+744 days
echo $interval->format('%y-%m-%d days')."<br>";
//2-0-14 days
// different between two dates by strtotime() function:-
$now = time(); // or your date as well
$your_date = strtotime("2010-01-01");
$datediff = $now - $your_date;
echo floor($datediff/(60*60*24)) ."<br>";
//744
?>
for more PHP questions and their best answers and PHP notes at http://onlinephpstudy.blogspot.com/
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Explain Creating and Naming an Array?
Is null function in php?
What is string function sql?
Why do you need php?
Tell me what are the correct and the most two common way to start and finish a php block of code?
What is list in PHP?
What is the difference between html and php?
Tell me what are the different types of errors in php?
How to create a session? How to remove data from a session?
How to remove all duplicate values in array in php?
Which method removes the last element from the end of an array?
Explain what does the unlink() function means?
Write a program in php to check whether a number is prime or not?
Does php have a future?
What are the features of php 7?