Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6961619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:33:15+00:00 2026-05-27T15:33:15+00:00

I have a value in the database defined as mediumint(11). Currently it returns 3600

  • 0

I have a value in the database defined as mediumint(11). Currently it returns 3600 if I run a query.

This function here should convert that value to: 1 hr. But it doesn’t when I run the function. I get no value.

function strTime($s) {
  $d = intval($s/86400);
  $s -= $d*86400;

  $h = intval($s/3600);
  $s -= $h*3600;

  $m = intval($s/60);
  $s -= $m*60;

  if ($d) $str = $d . 'd ';
  if ($h) $str .= $h . 'h ';
  if ($m) $str .= $m . 'm ';
  if ($s) $str .= $s . 's';

  return $str;
 }

Pretty basic, must be something with the value in the db?

Code that calls this (Joomla specific):

$query = "SELECT streaming_limit FROM #__cc_users WHERE user_id=".$user->id;
$db->setQuery($query);
$steaming_limit = $db->loadResult(); //returns 3600
echo strTime($streaming_limit); //returns nothing
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:33:15+00:00Added an answer on May 27, 2026 at 3:33 pm

    A more robust way to do this is PHP’s DateTime and DateInterval classes, which exist specifically for this sort of thing.
    The code below creates two DateTime objects, adds the specified number of seconds
    to one object and then calculates the interval between the two.

    At that point you can format the time difference however you’d like using DateInterval::format

    function strTimeDiff($seconds)
    {
      $date1 = new DateTime();
      $date2 = new DateTime();
      $date2->add(new DateInterval('PT'.$seconds.'S'));
      $interval = $date1->diff($date2);
    
      echo $interval->format('%d days, %h hours, %i minutes, %s seconds');
    }
    
    $secs_from_db = 3600;
    echo strTimeDiff($secs_from_db);
    // 0 days, 1 hours, 0 minutes, 0 seconds
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a checkbox in GridViewColumn which i use for show/change database value. The
i have a problem in inserting the listbox value into mysql database in vb
i have a problem in inserting the listbox value into mysql database in vb
I have a UTC DateTime value coming from a database record. I also have
I have a setting stored in database which has a value .jpg|.gif|.png . I
I have a table in SQL database: ID Data Value 1 1 0.1 1
I have a program that continually polls the database for change in value of
I have a custom control that shows a value obtained from the database (the
I have a date converted to double value and saved in database. Now, I
In my database, assume we have a table defined as follows: CREATE TABLE [Chemical](

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.