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

Ads
 

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 PHP?

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

Ads









Related Tutorials/Questions & Answers:
How can we know the number of days between two given dates using PHP?
days between two given dates using PHP
Advertisements
Javascript calculate number of days between two dates
Java get number of days between dates
calculate difference between two dates
How can we know the count/number of elements of an array?
What is the difference between PHP4 and PHP5?
display dates between two dates - Java Beginners
How to select Data Between Two dates in Java, MySQL
How can we find the number of rows in a result set using PHP?
How can we know that a session is started or not?
Hi .Difference between two Dates - Java Beginners
JavaScript check if date is between two dates.
how can i draw line between two panel contaning circle and line between their center?
mysql between dates not between dates
display diffrence between two dates in a text box - JSP-Servlet
to calculate the difference between two dates in java - Java Beginners
Jdbc connectivity in java to oracle for retrieving data between two dates
Comparing Dates in Java
Generate random number between two numbers in Scala
How can we solve this puzzle using java ?
Comparing two Dates in Java
How can we encrypt the username and password using PHP?
How can we create a database using PHP and mysql?
How can we get second of the current time using date function?
Difference in two dates - Java Beginners
How many ways we can pass the variable through the navigation between the pages?
What is the maximum size of a file that can be uploaded using PHP and how can we change this?
How to manage cookie in between two JSP Pages
Comparing two dates in java
Comparing two Dates in Java with the use of before method

Ads