I was wondering if someone could help me out taking the difference of timestamps in mysql or php. According to this website:
There is a DATEDIFF function that should return expr1-expr2.
When I try to use it I get an error that states: Parse error: parse error, unexpected T_STRING.
The tidbit of code that I am using for this can be used for this is:
$t=SELECT DATEDIFF ($col_value,$creation_ts);
I tried putting quotes around everything, but that still didn't work--any suggestions?
The format of the 2 dates is 2006-07-20 09:30:38.
Difference in Timestamps
1 reply to this topic
Posted 20 July 2006 - 02:29 PM
You have to run the DATEDIFF from a query as it is a mySQL function. In this case echoing would simply output SELECT DATEDIFF ($col_value,$creation_ts); (which would need quotes XD).
<?PHP $t="SELECT DATEDIFF ( ". $col_value . " ,". $creation_ts .")"; $diff = mysql_query($t); // I dont know how this should be returned, you may need a mysql_fetch_* of some sort. ?>
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users