How will you calculate days between two dates in PHP?

by trycia.jones , in category: Technology , 4 years ago

How will you calculate days between two dates in PHP?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by kenny , 4 years ago

Calculating days between two dates in PHP

1
2
3
4
5
6
<?php 
  $date1 = date('Y-m-d');
  $date2 = '2015-10-2';
  $days = (strtotime($date1)-strtotime($date2))/(60*60*24);
  echo $days;
?>

Related Threads:

How to get number of days between two given dates using PHP ?
How to Create a Composer Package in 2025?
What is difference Between PHP 5 and 7?
How to Use Php to Parse Json Data in 2025?
What Are the Key Differences Between Postgresql and Mysql?
What Are the Best Practices for Managing Oracle Sql Databases?