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:[EMAIL PROTECTED]]
Sent: Tuesday, November 13, 2001 2:47 PM
Subject: [PHP] date conversion and calculation problem...


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,


PHP General Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to