开发者

how i can know how many days between 2 date by php? [duplicate]

This开发者_运维技巧 question already has answers here: Closed 11 years ago.

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


<?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


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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜