Can I shorten this function?
$mins = $secs - time('u');
function minutes($seconds){
return sprintf( "%2.2dm %2.2ds", floor($seconds/60),$seconds%60);}
$mins_left = minutes($mins);
echo "Resets in $mins_left.";
Can I shorten this function?
$mins = $secs - time('u');
function minutes($seconds){
return sprintf( "%2.2dm %2.2ds", floor($seconds/60),$seconds%60);}
$mins_left = minutes($mins);
echo "Resets in $mins_left.";
Can I shorten this function?
If for function you're meaning function minutes($seconds)
, well, I think you can't. if you want to shorten up your whole code, than you could remove minutes
at all, but I don't know if it's okay for you.
$mins = $secs - time('u');
$mins_left = sprintf( "%02:%02 mm:ss", floor($mins/60),$mins%60);
echo "Resets in $mins_left.";
Considering that's only a sprintf, you could handle it as a macro...
The function minutes() is confusing.
It takes a number of minutes as an argument and return a string with minutes and seconds.
Why then use $seconds within the function?