gladiator83x Posted July 20, 2006 Share Posted July 20, 2006 Hi All,I was wondering if someone could help me out taking the difference of timestamps in mysql or php. According to this website:http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.htmlThere 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);echo $t;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. Quote Link to comment https://forums.phpfreaks.com/topic/15147-difference-in-timestamps/ Share on other sites More sharing options...
ChaosXero Posted July 20, 2006 Share Posted July 20, 2006 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).[code]<?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.?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15147-difference-in-timestamps/#findComment-61030 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.