Answers for "how to convert how to convert time to seconds in php"

PHP
3

seconds to minutes php

echo gmdate("H:i:s", 685);
Posted by: Guest on August-04-2020
0

php timestamp to seconds

function ago($time) { 
    $timediff=time()-$time; 

    $days=intval($timediff/86400);
    $remain=$timediff%86400;
    $hours=intval($remain/3600);
    $remain=$remain%3600;
    $mins=intval($remain/60);
    $secs=$remain%60;

    if ($secs>=0) $timestring = "0m".$secs."s";
    if ($mins>0) $timestring = $mins."m".$secs."s";
    if ($hours>0) $timestring = $hours."u".$mins."m";
    if ($days>0) $timestring = $days."d".$hours."u";

    return $timestring; 
}
echo ago(1334214962);
Posted by: Guest on January-31-2022

Code answers related to "how to convert how to convert time to seconds in php"

Browse Popular Code Answers by Language