RE: [PHP] Need a function to calculate time difference.

2003-07-04 Thread Boaz Yahav
See if this helps you

Getting the difference between two time strings.
http://examples.weberdev.com/get_example.php3?count=3307

Difference between two dates (i.e. between today and a date in future).
The program is 
based on php-timestamp, but in your browser you see the usual
dates(i.e.: dd.mm.)
http://examples.weberdev.com/get_example.php3?count=3240

Sincerely

berber

Visit http://www.weberdev.com/ Today!!!
To see where PHP might take you tomorrow.


-Original Message-
From: Jack Sasportas [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 03, 2003 10:17 PM
To: php
Subject: Re: [PHP] Need a function to calculate time difference.


datetime.

Thanks

Jim Lucas wrote:

what type of format does your column take?

date
time
datetime

??

Jim Lucas
- Original Message -
From: Jack Sasportas [EMAIL PROTECTED]
To: php [EMAIL PROTECTED]
Sent: Wednesday, July 02, 2003 2:11 PM
Subject: [PHP] Need a function to calculate time difference.


  

I am trying to find a function or information on how to properly take 
a
start time and an end time from mysql timestamps in order to calculate

time taken.
So in theory $endtime-$starttime = timespent.

It would be great if this understood that 11:55 pm til 12:10am one day
apart only equals 15 minutes.

Links, example code etc would be great!

Thanks


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php







  




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need a function to calculate time difference.

2003-07-03 Thread Jack Sasportas
datetime.

Thanks

Jim Lucas wrote:

what type of format does your column take?

date
time
datetime
??

Jim Lucas
- Original Message - 
From: Jack Sasportas [EMAIL PROTECTED]
To: php [EMAIL PROTECTED]
Sent: Wednesday, July 02, 2003 2:11 PM
Subject: [PHP] Need a function to calculate time difference.

 

I am trying to find a function or information on how to properly take a 
start time and an end time from mysql timestamps in order to calculate 
time taken.
So in theory $endtime-$starttime = timespent.

It would be great if this understood that 11:55 pm til 12:10am one day 
apart only equals 15 minutes.

Links, example code etc would be great!

Thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   



 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Need a function to calculate time difference.

2003-07-02 Thread Jack Sasportas
I am trying to find a function or information on how to properly take a 
start time and an end time from mysql timestamps in order to calculate 
time taken.
So in theory $endtime-$starttime = timespent.

It would be great if this understood that 11:55 pm til 12:10am one day 
apart only equals 15 minutes.

Links, example code etc would be great!

Thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Need a function to calculate time difference.

2003-07-02 Thread Jim Lucas
what type of format does your column take?

date
time
datetime

??

Jim Lucas
- Original Message - 
From: Jack Sasportas [EMAIL PROTECTED]
To: php [EMAIL PROTECTED]
Sent: Wednesday, July 02, 2003 2:11 PM
Subject: [PHP] Need a function to calculate time difference.


 I am trying to find a function or information on how to properly take a 
 start time and an end time from mysql timestamps in order to calculate 
 time taken.
 So in theory $endtime-$starttime = timespent.
 
 It would be great if this understood that 11:55 pm til 12:10am one day 
 apart only equals 15 minutes.
 
 Links, example code etc would be great!
 
 Thanks
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need a function to calculate time difference.

2003-07-02 Thread Larry R. Sieting
Hi,

I just went through this... for my daughters drive time for a level one 
michigan license.  Thanks to Wendell Brown for the help.

following is my create table command;

CREATE TABLE `mileage` 
( 

   `id` int(11) NOT NULL 
auto_increment, 

   `drive_date` varchar(12) NOT NULL default 
'', 

   `start_time` time NOT NULL default 
'00:00:00', 

   `end_time` time NOT NULL default 
'00:00:00', 

   `start_miles` decimal(6,1) NOT NULL default 
'0.0', 

   `end_miles` decimal(6,1) NOT NULL default 
'0.0', 

   `type_of_driving` tinytext NOT 
NULL, 

   PRIMARY 
KEY  (`id`) 

 ) TYPE=MyISAM

At 05:11 PM 7/2/2003 -0400, you wrote:
I am trying to find a function or information on how to properly take a 
start time and an end time from mysql timestamps in order to calculate 
time taken.
So in theory $endtime-$starttime = timespent.

It would be great if this understood that 11:55 pm til 12:10am one day 
apart only equals 15 minutes.

Links, example code etc would be great!

Thanks


$sql = Select ID, drive_date, start_time, end_time, start_miles, 
end_miles, type_of_driving FROM mileage;
$result = mysql_query( $sql );
if ( $result != false )
{
$drive=Drive date: 
%sbr;// Formatting the output
$sstime=Start Time: %sbr;
$setime=End Time: %sbr;
$ssmiles=Start Miles: %sbr;
$tot_tim=Total Time: %sbr;
$semiles=End Miles: %sbr;
$tot=Total Miles: %6.1fbr;
$tod=Type of Driving: %sbrbr;
while ( $data = mysql_fetch_assoc( $result ) 
)  // Loading the array
{
$tot_miles = ($data[end_miles] - 
$data[start_miles]);   //calculate total miles

This is the time calculations section

$sTime = strtotime( $data[start_time] );
$eTime = strtotime( $data[end_time] );
$tot_time = $eTime - 
$sTime;// Elapsed Seconds

printf($drive,$data[drive_date]);
printf($sstime,$data[start_time]); 
// display start time
printf($setime,$data[end_time]); 
// display end time
printf( $tot_tim,gmstrftime( %H:%M, 
$tot_time ) );// display total time driving
printf($ssmiles,$data[start_miles]); 
// display start miles
printf($semiles,$data[end_miles]); 
// display end miles
printf( $tot, $tot_miles 
); // display total miles driven
printf($tod,$data[type_of_driving]);
}
} else {
echo mysql_error();
}

}


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Gilebert/Larry