Online Forum To Support Coders With Technical Assistance - Read Write Execute

convert seconds into formatted time

Ankit Agrawal
Ankit Agrawal
Published on August 30, 2016 · 1 min read
function convertTime($sec) {
$dta = new \DateTime('@0');
$dtb = new \DateTime("@$sec");
return $dta->diff($dtb)->format('%a days, %h hours, %i minutes and %s seconds');
}
Was this article helpful?
Ankit Agrawal

Ankit Agrawal

Author & Senior Engineer at CodeExecute

Writing practical engineering guides, debugging real-world bottlenecks, and creating free tools for developer productivity.

← Previous Article Detect Mousewheel events by jQuery Next Article → Add two background color using css