---
title: "How can we know the number of days between two given dates using PHP?"  
description: "How can we know the number of days between two given dates using PHP?"  
author: "Chris Anderson"  
published: 2011-09-17  
updated: 2020-09-17  
canonical: https://www.mindstick.com/interview/1261/how-can-we-know-the-number-of-days-between-two-given-dates-using-php  
category: "php"  
tags: ["php"]  
reading_time: 1 minute  

---

# How can we know the number of days between two given dates using PHP?

Simple arithmetic:\
\
$date1 = date('Y-m-d');\
$date2 = '2006-07-01';\
$days = (strtotime() - strtotime()) / (60 * 60 * 24);\
echo "Number of days since '2006-07-01': $days";

## Answers

### Answer by Chris Anderson

Simple arithmetic:\
\
$date1 = date('Y-m-d');\
$date2 = '2006-07-01';\
$days = (strtotime() - strtotime()) / (60 * 60 * 24);\
echo "Number of days since '2006-07-01': $days";


---

Original Source: https://www.mindstick.com/interview/1261/how-can-we-know-the-number-of-days-between-two-given-dates-using-php

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
