-1

I want to calculate days between 2 month.1 date is set that is 01-03-2014 and second date will be given by user.This may be any date for example 14-05-2014.Now i want to calculate days between these 2 dates? Thanks

taleeb
  • 9
  • 4
  • See [DateTime class](http://php.net/manual/en/class.datetime.php) and [DateInterval class](http://php.net/manual/en/class.dateinterval.php). – Kryten Dec 19 '14 at 16:39
  • One day at a time.... – duffymo Dec 19 '14 at 16:39
  • What code have you tried so far? Or are you just asking for so called "homework" help? Because SO users generally only help with the former, not the later. – Chrismas007 Dec 19 '14 at 16:39
  • possible [duplicate](http://stackoverflow.com/questions/1940338/date-difference-in-php-on-days) –  Dec 19 '14 at 16:40

1 Answers1

1

You can use DateTime for this, and do a simply calculation. See DateTime:diff

<?php

$start= new DateTime('14-05-2014');
$end= new DateTime('01-03-2014');
$interval = $start->diff($end);

echo $interval->format("%a total days"); //Output: 74 total days

https://eval.in/236630

ʰᵈˑ
  • 11,279
  • 3
  • 26
  • 49