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?

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









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
What is the difference between PHP4 and PHP5?
How can we know the count/number of elements of an array?
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?
Hi .Difference between two Dates - Java Beginners
list of all months between two dates in java
list of all months between two dates in java
How can we know that a session is started or not?
JavaScript check if date is between two dates.
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
Generate random number between two numbers in Scala
Generate random number between two numbers in Scala
Jdbc connectivity in java to oracle for retrieving data between two dates
how can i draw line between two panel contaning circle and line between their center?
Comparing Dates in Java
Comparing two Dates in Java
Difference in two dates - Java Beginners
How can we solve this puzzle using java ?
ModuleNotFoundError: No module named 'phpy'
How to manage cookie in between two JSP Pages
how to get string between two characters
Comparing two dates in java
calculate difference between two time in jsp
How many ways we can pass the variable through the navigation between the pages?
Midpoint of two number
Java get number of Days in Month
Multiplication of Two Number in Class
Comparing two Dates in Java with the use of before method
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?
How to find out the friend user between two columns in sql database
Prime Number in Java
Two Element Dividing Number
mysql difference between two numbers
validation on dates - Java Beginners
how to create directed line between two buttons when i clicked there
How to get of lastmodified file list between two times in java?
PHP Date compare the dates, PHP Compare dates example
Squaring of two number in Static class
How we can integrate ASP .net website to payment gateway using SOAP xml request and response using wsdl.
Annotations are using now a days?

Ads