Re: Question about date calculations
| From: | Fatih P. | Date: | Thu, 29 Dec 2011 22:09:47 +0000 |
| Subject: | Re: Question about date calculations | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-316126@lists.php.net to get a copy of this message | ||
On Thu, Dec 29, 2011 at 11:40 PM, Frank Arensmeier <farensmeier@gmail.com>wrote:
> 29 dec 2011 kl. 22.22 skrev Eric Lommatsch:
>
> > So far in looking at the functions that are available at
> > http://www.php.net/manual/en/ref.datetime.php I have not
> > been able to
> figure
> > out how to do what I need to do. Below is a snippet showing
> approximately
> > what I am trying to do.
>
> On the same page you are referring, there are plenty of examples on how to
> calculate the difference between two dates. Choose one and see if it fits
> your bill. Or is there any particular reason why you're writing your "own"
> function?
>
> http://www.php.net/manual/en/ref.datetime.php#78981
>
> /frank
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
since you have everything in database tables why not to do this calculation
on database side which would be much appropriate place ?
/* columns
date_start = '2011-02-08';
date_end = ' 2011-03-04';
*/
select DATEDIFF(date_end, date_start);
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_datediff