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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.