![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP program to find the total number of date between any two given dates
The ‘date_diff’ function can be used to get the difference between two dates. It is a built-in function that returns a DateInterval object if a specific number of days has been found, and returns False if the days is not found.
Example
<?php $date_1 = date_create('23-11-2019'); $date_2 = date_create('22-1-2020'); $day_diff = date_diff($date_1, $date_2); echo $day_diff->format('The day difference is: %R%a days'); ?>
Output
The day difference is: +60 days
Two dates are defined using the ‘date_create’ function and the difference/ the number of days that are present between these two dates can be computed using the ‘date_diff’ function. It is assigned to a variable and printed on the console.
Advertisements