Got a problem with time and posting into MySQL
Posted: Thu Sep 15, 2005 7:30 pm
Current Versions:
PHP Version 5.0.4
MySQL 4.1.14
phpMyAdmin 2.6.3-pl1
Apache/2.0.54 (Win32)
Ok I have a project im working on for my work and even tho i've been around php for a number of years this is really taxing my idea's.
My main problem is that i have a form where people fill out their info. Two fields are Starttime and Endtime all in Military time (ie 13:00 and 15:00 hrs). My problem is that im tryin to get the total amount of hours between two different times, 13:00-15:00, correct format. All i get is 2 and that it.
This is what i have in the form assigntask.php file
After you hit submit it runs the file process.php which is where it pops it into the DB. I'm able to get it to add the 2 to the DB but again i need it in the right format. Also if i do a time with minutes in it (ie. 10:00 - 15:45) then it kicks out the 45mins and will only add the 5hrs.
If i use something like this in the process.php portion then i get a 5:00:02
Please if anybody could help me out here i would greatly appreciate it.. I still have a little hair left.
PHP Version 5.0.4
MySQL 4.1.14
phpMyAdmin 2.6.3-pl1
Apache/2.0.54 (Win32)
Ok I have a project im working on for my work and even tho i've been around php for a number of years this is really taxing my idea's.
My main problem is that i have a form where people fill out their info. Two fields are Starttime and Endtime all in Military time (ie 13:00 and 15:00 hrs). My problem is that im tryin to get the total amount of hours between two different times, 13:00-15:00, correct format. All i get is 2 and that it.
This is what i have in the form assigntask.php file
Code: Select all
Start Time: (HH:MM)</td>
<td height="30" width="469" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana"><input type=text name='starttime' size=5>* (military time)</td></tr><tr><td height="30" width="55" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<img border="0" src="bc_new.gif" width="28" height="28"></td><td height="30" width="189" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">
End Time: (HH:MM)</td>
<td height="30" width="469" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana"><input type=text name='endtime' size=5>* (military time)</td></tr><tr><td height="30" width="55" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<img border="0" src="bc_new.gif" width="28" height="28"></td><td height="30" width="189" bgcolor="#EFF3F7" bordercolor="#FFFFFF">
<font face="Verdana" size="2">If i use something like this in the process.php portion then i get a 5:00:02
Code: Select all
$hoursspent = date('h:i:s',$endtime - $starttime);