RE: [PHP] Date subtraction
| From: | Jeff Armstrong | Date: | Fri, 23 Mar 2001 14:01:47 +0000 |
| Subject: | RE: [PHP] Date subtraction | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-45284@lists.php.net to get a copy of this message | ||
Do it in MySQL = Fast
Don't fiddle in PHP = waste of your time.
Look into the following:
select
UNIX_TIMESTAMP(date1)-UNIX_TIMESTAMP(date1) as diff_secs,
TO_DAYS(date1)-TO_DAYS(date1) as diff_days,
PERIOD_DIFF(date1,date2) as diff_months,
YEAR(date1) - YEAR(date2) as diff_years
from MYTABLE
where id=$id
I'm not sure what
select date1-date2 as date_diff
returns?
beware of the 2037 limitation using UNIX_TIMESTAMP()
regards
Jeff
-----Original Message-----
From: BlackLord [mailto:black_lordus@yahoo.com]
Sent: Thursday, March 22, 2001 5:41 PM
To: php-general@lists.php.net
Subject: [PHP] Date subtraction
Hi!
I want to subtract to date times from each other. Like :
'2000 12 01 12:12:12' - '2000 11 10 11:39:59'
Is there any function to do this subtraction or can i do it with MySQL's
SELECT query ?
Thanks
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net