Jump to content

getting just the minutes by itself


ecabrera

Recommended Posts

ok so here is my code

  $t = round($seconds);
  echo sprintf('%02d:%02d:%02d', ($t/3600),($t/60%60), $t%60);

the $t is the h m s in seconds

 

i want to just get the minutes so than i can do something like this 

 

if($t <= 1500){
$t = 900;
}
if($t <= 2100){
  $t = 1800;
}
if($t <= 3300){
  $t = 2700;
}
if($t <= 3600){
  $t = $t + 216000;
}
 
so the result can be something like this
3 hr 15mins
3hr 30min
3hr 45min
4
 
is this something i can do?
Link to comment
https://forums.phpfreaks.com/topic/295510-getting-just-the-minutes-by-itself/
Share on other sites

What are you beginning with? IE, what is $seconds defined as (int,str,datetime?) and what do you store in it? Since you are using a round function I can only assume that it is an integer. Therefore I would assume that you put some kind of unix time into it to start and therefore any date() function should output what you want or allow you to do math on it.

 

What have you tried so far?

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.