$value = 90;
echo gmdate("i:s", $value)."<br>";
the output is: 01:30
How do I format:
1:30
$value = 90;
echo gmdate("i:s", $value)."<br>";
the output is: 01:30
How do I format:
1:30
The i
character refers to minutes with leading zeros. You can use intval
to remove the leading zeros:
echo intval(gmdate("i", $value)) . gmdate(":s", $value) . "<br />";
From the box of trickses:
$str = '01:30';
echo substr_replace($str, '', 0, min(1, strspn($str, '0')));
Try gmdate("g:s",$value)) (or capital G for 24-hour format)
See all your formatting options: PHP date formatting