Jump to content

PHP auto truncates my zeros


xnowandtheworldx

Recommended Posts

On my website for users to upload their gaming videos, when i'm formatting the seconds into minutes when there is a 0 in the duration for some reason it gets truncated and i've scoured the internet and found nothing....

 

i've tried (int) and intval() so any help would be greatly appreciated!

 

$mins = floor($duration_first / 60);
$secs = $duration_first % 60;
$duration = $mins.":".$secs;

 

and then i store it in a table as varchar

Link to comment
https://forums.phpfreaks.com/topic/98562-php-auto-truncates-my-zeros/
Share on other sites

That'll do the time.  Here's an example of forcing it to leave the leading zeros (would be useful if you're not working with dates).  I thought I'd go ahead and post it anyway seeing as I was already to post it anyway.

http://us3.php.net/sprintf

$mins = floor($duration_first / 60);
$secs = $duration_first % 60;
$duration = sprintf("%02d:%02d", $mins, $secs);

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.