sandy1028 Posted September 11, 2007 Share Posted September 11, 2007 Hi, I am facing problem in converting to time. select sec_to_time(unix_timestamp(now())-unix_timestamp(timestamp)) from Tablename where name= '".$name."'"; Here when values exceeds 838:59:59 how to get the exact value of time. Other than sec_to_time() is there any other function which gives the exact value Quote Link to comment Share on other sites More sharing options...
sandy1028 Posted September 11, 2007 Author Share Posted September 11, 2007 Please help me how to convert seconds to Number of days, hours and min. Is there any built-in function Quote Link to comment Share on other sites More sharing options...
Aeglos Posted September 11, 2007 Share Posted September 11, 2007 I you want to convert an amount of seconds into hours:minutes:seconds try this: <?php function foo($seconds) { $hours = floor($seconds/3600); $timeleft = $seconds - ($hours*3600); $minutes = floor($timeleft/60); $seconds = $timeleft - ($minutes*60); echo $hours.':'.$minutes.':'.$seconds; } ?> There's bound to be some better way to do this, and you'll probably have to modify it to use it in... whatever is it that you need it... but I really didn't catch entierely what you were trying to do anyway Cheers. Quote Link to comment 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.