RE: [PHP] date conversion and calculation problem...

From: Date: Tue, 13 Nov 2001 03:47:03 +0000
Subject: RE: [PHP] date conversion and calculation problem...
Groups: php.general 
Request: Send a blank email to php-general+get-74356@lists.php.net to get a copy of this message
Is this a direct copy of your code? if so, there's an error on this line $t1 = mktime( $arr_time1[0], $arr_time1[1], $arr_time1[2], $arr_date1[1], $arr_date1[1], $arr_date1[0] ); should be: $t1 = mktime( $arr_time1[0], $arr_time1[1], $arr_time1[2], $arr_date1[1], $arr_date1[2], $arr_date1[0] ); Martin T -----Original Message----- From: py [mailto:pylem@sympatico.ca] Sent: Tuesday, November 13, 2001 2:47 PM To: php-general@lists.php.net Subject: [PHP] date conversion and calculation problem... Hello, I have 2 date string like this $t1 = "2001-11-12 17:30:10"; $t2 = "2001-11-12 17:15:32"; I need to substracts the number of seconds from $t2 from $t1 (because after I have another script thats converts the number of seconds to minutes, hours or days if necessary) I tried: (but it does not give me something rigth) $t1 = explode( " ", $t1 ); $t2 = explode( " ", $t2 ); // now $t1[0] contains date $t1[1] contains hours $arr_date1 = explode( "-", $t1[0] ); $arr_date2 = explode( "-", $t2[0] ); $arr_time1 = explode( ":", $t1[1] ); $arr_time2 = explode( ":", $t2[1] ); // now $arr_time1[0] contains the hour, $arr_time1[1] contains minute, $arr_time1[2] contains second $t1 = mktime( $arr_time1[0], $arr_time1[1], $arr_time1[2], $arr_date1[1], $arr_date1[1], $arr_date1[0] ); $t2 = mktime( $arr_time2[0], $arr_time2[1], $arr_time2[2], $arr_date2[1], $arr_date2[2], $arr_date2[0] ); print "<br>$t2 - $t1 = ". ( $t2 - $t1); hope you can help me, py -- 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 (#74356) next »