Jump to content

Recommended Posts

Hey all I've got a simple problem of what I believe but its becoming a pain, I'm simply selecting a time from the database which is inputted in then I want to display it in Minutes and seconds;

 

This is what I have. I should display the time I have left as I have got time left to wait although its always showing I'm free?

 

Any reason behind this?

 

Thanks for any help!

if ($UsersTable1->action1time  > time()){
$left = $UsersTable1->action1time  - time();
 
$mins = floor($left / 60); // number of whole minutes left
$secs = sprintf('%02d', $left % 60); // remainder of time left (in seconds) divided by 60.
 
$Time = "$mins min and $secs secs";
 
}else{
$Time = "Free!";
}
Edited by dean7
Link to comment
https://forums.phpfreaks.com/topic/302189-displaying-time-from-database/
Share on other sites

That date was back in 2012, so clearly it's not in the future.

 

By the way, storing timestamps as integers is very bad practice. Not only is it very confusing (as you can see). It also makes date calculations a lot harder.

Whats the best way todo this then?

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.