0

Possible Duplicates:
How to count days between two dates in PHP?
Full Days between two dates in PHP?

how i can know how many days between 2 date ex: i want know how many days between 12\02\2011 and 15\03\2011

please help me

Community
  • 1
  • 1
Kareem Nour Emam
  • 1,054
  • 4
  • 14
  • 27
  • Use Stack Overflow's search box? – Jon Feb 19 '11 at 04:11
  • 2
    Not really relevant, but: you are using backslashes instead of slashes. This is not a date: 12\02\2011. This is: 12/02/2011. This is even better: 2011-12-31 (international format). Thought I’d mention it because this could be the source of your frustrations (and because it irked me). – Alan H. Feb 19 '11 at 04:15

2 Answers2

1
<?php
$datetime1 = date_create('2011-02-12');
$datetime2 = date_create('2012-03-15');
$interval = date_diff($datetime1, $datetime2);
echo $interval->format('%R%a days');
?>

You dates just have to be of one of the following formats:
PHP Date formats

AdamJonR
  • 4,703
  • 2
  • 22
  • 24
0

http://ca.php.net/manual/en/datetime.diff.php

look at the example. it gives you pretty much exactly what you asked.

mpen
  • 272,448
  • 266
  • 850
  • 1,236