Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to convert given seconds into day format using PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 302
    Comment on it

    On converting the given time in seconds you have to follow the calculation in days and hours etc. Using PHP you can get the format by using the code below:-

    Here I created the function ConvertToSec ($sec) as param:

      function ConvertToSec($sec) {
        $DateTime = new DateTime("@0");
        $DateTimeNew = new DateTime("@$sec");
        return $DateTime->diff($DateTimeNew)->format('%a days, %h hours, %i minutes and %s seconds');
    }
    

    Lets pass the seconds in function

     echo ConvertToSec(1642359)
    

    Output:-

    19 days, 0 hours, 12 minutes and 39 seconds
    

    And it workd perfect for me.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: