Jump to content

Time problem


sandy1028

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/68811-time-problem/
Share on other sites

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  ;D

 

Cheers.

 

 

Link to comment
https://forums.phpfreaks.com/topic/68811-time-problem/#findComment-345874
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.