Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa PHP How can we know the number of days between two given dates using PHP?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


brijesh
How can we know the number of days between two given dates using PHP?
1 Answer(s)      4 years and a month ago
Posted in : PHP


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


Advertisement
View Answers

November 13, 2010 at 3:21 PM


Hi,

The code to find the number of days is:

<?php

function numberofdays($startdate, $enddate) {

$start = strtotime($startdate);

$end = strtotime($enddate);

$difference = $end - $start;

return round($difference / 86400);

}

echo numberofdays("2006-04-05", "2006-04-01");

?>

Thanks



Related Tutorials/Questions & Answers:
Advertisements
Advertisements
 

 

 

DMCA.com