Re: subtract dates
| From: | tedd | Date: | Thu, 02 Mar 2006 00:31:41 +0000 |
| Subject: | Re: subtract dates | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-231296@lists.php.net to get a copy of this message | ||
Benjamin:
I'm trying subtract to dates the user enters in and get the days between. Dates are stored as date('mdY') is there a built in function to subtract to dates is this format?Try this for starters: <?php $century = mktime(12, 0, 0, 1, 1, 2001); $today = time(); $difference = $today - $century; echo 'This century started '; echo floor($difference / 84600); $difference -= 84600 * floor($difference / 84600); echo ' days, '; echo floor($difference / 3600); $difference -= 3600 * floor($difference / 3600); echo ' hours, '; echo floor($difference / 60); $difference -= 60 * floor($difference / 60); echo " minutes, and $difference seconds ago."; ?> There are other examples at: http://www.weberdev.com/get_example-3646.html http://www.weberdev.com/get_example-3240.html http://www.weberdev.com/get_example-95.html tedd -- -------------------------------------------------------------------------------- http://sperling.com