note 38069 added to function.checkdate
| From: | moon at justmoon dot de | Date: | Sun, 07 Dec 2003 09:18:50 +0000 |
| Subject: | note 38069 added to function.checkdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-61586@lists.php.net to get a copy of this message | ||
@carsten:
Your method to calculate the days between two dates doesn't need to be that complicated.
Try this (quick 'n' dirty):
function diff_days($start_date, $end_date
{
return floor(abs(strtotime($start_date) - strtotime($end_date))/86400);
}
// You can use whatever days you want
echo diff_days("20031013", "20040105"); // result: 84
// You can use every format strtotime supports
echo diff_days("now", "-1 year");
// You can mix start and end
echo diff_days("20031203", "20031201"); // result: 2
----
Manual Page -- http://www.php.net/manual/en/function.checkdate.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38069
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38069&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38069&report=yes
Search -- http://master.php.net/manage/user-notes.php