Convert seconds into days, hours, minutes and seconds

后端 未结 24 2607
说谎
说谎 2020-11-22 16:30

I would like to convert a variable $uptime which is seconds, into days, hours, minutes and seconds.

Example:



        
24条回答
  •  再見小時候
    2020-11-22 17:07

    foreach ($email as $temp => $value) {
        $dat = strtotime($value['subscription_expiration']); //$value come from mysql database
    //$email is an array from mysqli_query()
        $date = strtotime(date('Y-m-d'));
    
        $_SESSION['expiry'] = (((($dat - $date)/60)/60)/24)." Days Left";
    //you will get the difference from current date in days.
    }
    

    $value come from Database. This code is in Codeigniter. $SESSION is used for storing user subscriptions. it is mandatory. I used it in my case, you can use whatever you want.

提交回复
热议问题