Using "time" var from database
Posted: Thu Feb 05, 2004 10:14 am
My data is stored as "time" columns in the database and returns in the array as strings in the form of "00:00:00". (At least it appears to, PHP is so loosely typed one cannot always be absolutely certain what one is looking at.) Anyway...
Are there any PHP functions for manipulating that data? Like subtracting a start time from a finish time to establish an elapsed time. If it were a "datetime" column I could ise the date() functionality, but I've checked in PHP docs and MySQL docs and done a search in these forums (fora?) and I cannot find anything similar for the "time" string.
Similarly with numbers stored as type "decimal" in MySQL. I know they are stored as strings, but I assume I can convert them simply enough by doing
and then I have it in numeric form. I will experiment to confirm that as soon as I get back from a client call later today, but that clearly isn't going to fly for the time data.

Are there any PHP functions for manipulating that data? Like subtracting a start time from a finish time to establish an elapsed time. If it were a "datetime" column I could ise the date() functionality, but I've checked in PHP docs and MySQL docs and done a search in these forums (fora?) and I cannot find anything similar for the "time" string.
Similarly with numbers stored as type "decimal" in MySQL. I know they are stored as strings, but I assume I can convert them simply enough by doing
Code: Select all
<?php
$Amount = 0.00 + $Row['Amount'];
?>