I was wondering, if I record a time through a javascript function and say I leave it on for 2 mins 20 seconds:
00.02.20
now when I insert this into my database, where the field type is set as time, it doesn’t record properly.
I think it comes from how I request the data:
$length = mysql_escape_string($_REQUEST['timeDrive']);
is there a way of converting this into a time that is going to output the exact value:
00.02.20
thanks for the help!
If you don’t need to perform any mathematical functions on those fields (eg: sum, average, etc), and it’s purely for display, then you can just store it as plain text in a
CHAR(8)field.Otherwise, you’ll need to normalise it to some sort of unit. I’d suggest maybe as an integer of the total number of seconds (if that is accurate enough for you).
To convert to seconds:
And to convert it back: