-1
$value = 90;
echo gmdate("i:s", $value)."<br>";

the output is: 01:30

How do I format:

 1:30
tree em
  • 20,379
  • 30
  • 92
  • 130
  • @Jack This question is dealing with `gmdate` and has a second component, which does not make it an *exact* duplicate. – Kermit Mar 22 '13 at 14:51
  • `gmdate()` or `date()` is the same thing; regardless, the referenced question covers the same grounds. – Ja͢ck Mar 22 '13 at 15:02

3 Answers3

4

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 />";
Kermit
  • 33,827
  • 13
  • 85
  • 121
  • @BandOfBrothers Not according to [this demo](http://codepad.org/ztUQJPM3). – Kermit Mar 22 '13 at 14:53
  • I was searching for kinda of this answer for the last 3 hours and i am upvoting this. According to my needs it shows time perfectly. – lonerunner Aug 05 '14 at 15:57
0

From the box of trickses:

$str = '01:30';

echo substr_replace($str, '', 0, min(1, strspn($str, '0')));
Ja͢ck
  • 170,779
  • 38
  • 263
  • 309
-1

Try gmdate("g:s",$value)) (or capital G for 24-hour format)

See all your formatting options: PHP date formatting

vidario
  • 479
  • 2
  • 5