Re: Date subtraction

From: Date: Sat, 24 Mar 2001 00:24:05 +0000
Subject: Re: Date subtraction
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-45370@lists.php.net to get a copy of this message
thanks for your help. ""Jeff Armstrong"" <jeff.armstrong@pirum.com> wrote in message news:NFBBLGBDNILEEAOGBCFEAEHOCAAA.jeff.armstrong@pirum.com... > 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 > > > -- > 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 >

« previous php.general (#45370) next »