Australia's Leading Digital Marketing Experts. T. 1300 235 433  |  Aggregation Enquires Welcome

Example Interest Rates: Home Loan Variable: 2.54% (2.74%*) • Home Loan Fixed: 3.74% (3.8%*) • Fixed: 2.48% (2.94%*) • Variable: 2.54% (2.74%*) • Investment IO: 2.3% (3.76%*) • Investment PI: 2.04% (3.8%*)

Convert Seconds to HH:MM:SS

The following will convert seconds to an HH:MM:SS format.

$result = gmdate('H:i:s', ($seconds));

To add the 's' for seconds (it puts the time into perspective), use:

$result = gmdate('H:i:s', ($seconds)) . 's';

For anything under a minute, you might want to strip the leading 00:00.

$result = ltrim(gmdate('H:i:s', ($seconds)), '00:') . 's';

While printing an 's' gives the time a reference, you might want to keep the leading 00: at times even when there's no hour. Use the following:

$result = ltrim(gmdate('H:i:s', ($seconds)), '00:00:') . 's';

■ ■ ■

Reference: PHP Manual, time() and date() .

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  AUS Eastern Standard Time (Washington)

  Want to have a chat?

Like this article?

Share on facebook
Share on Facebook
Share on twitter
Share on Twitter
Share on linkedin
Share on Linkdin
Share on pinterest
Share on Pinterest

Leave a comment