Jump to content

getting just the minutes by itself


ecabrera
Go to solution Solved by 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
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?

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.