# time()

## Recommended Posts

hi all,i got 1 for you i am placing this in my DB...\$time = time() - 259200;witch is (now - 3 days) and i am using VAR (50) in my DB how can i pull this out on my DB to show on the page... "2days,7hours,34min left" i looked at...http://www.w3schools.com/php/func_date_time.aspbut it only shows days and i need time any help?

##### Share on other sites

It's just basic math. You divide by 86400 to get the days. You divide the remainder by 3600 to get the number of hours. Divide the remainder by 60 to get the number of minutes, etc.

##### Share on other sites

got it!!!... i 1st tryed...

`function time_elapsed_A(\$secs){    \$bit = array(	    'y' => \$secs / 31556926 % 12,	    'w' => \$secs / 604800 % 52,	    'd' => \$secs / 86400 % 7,	    'h' => \$secs / 3600 % 24,	    'm' => \$secs / 60 % 60,	    //'s' => \$secs % 60	    );	      foreach(\$bit as \$k => \$v)	    if(\$v > 0)\$ret[] = \$v . \$k;	      return join(' ', \$ret);    }\$nowtime = time();\$dis_time_left = time_elapsed_A(\$dis_d_time_indb - \$nowtime)."\n";`

and i found a bug in this so i made...

`\$nowtime = time();\$secs = (\$dis_d_time_indb - \$nowtime);\$day_left = \$secs / 86400 % 7;\$hour_left = \$secs / 3600 % 24;\$min_left = \$secs / 60 % 60;\$dis_time_left = '' . \$day_left .' D ' . \$hour_left . ' H ' . \$min_left . ' M '';`

and this works for me 100% of the time thank you and please comment