Bladephp: Now with 7+ codeigniter, php, and laravel project 7+ php project From $18/Year From Rs. 1000/Year

How to convert Seconds into Minutes and Hours using PHP

by
Category:php
php html
How to convert Seconds into Minutes and Hours using PHP

In this simple article we will show you how to convert seconds into minutes and hours using PHP. This is a simple PHP code that converts a seconds into a minuts and hourse. You may also like How to Currency Converter using PHP and Google API and How to convert bytes Into KB, MB and GB using PHP.

HTML Code

<html>
    <body>
        <form method="post"action="">
            <input type="text" name="time" placeholder="Enter Seconds">
            <select name="convert_unit">
                <option>Minutes</option>
                <option>Hours</option>
            </select>
            <br>
            <input type="submit" name="convert_seconds" value="Convert Seconds">
        </form>
        <p><?php echo $time; ?></p>
    </body>
</html>

PHP Code

<?php
$time = '';
if(isset($_POST['convert_seconds']))
{
    $time   =   $_POST['time'];
    $unit   =   $_POST['convert_unit'];
    if($unit == "Minutes")
    {
        $time = round($time / 60,4) . 'Min';
    }
    if($unit == "Hours")
    {
        $time = round($time / 60 / 60,4) . 'Hours';	
    }
}
?>

0 Comments


Html code work in comment box


Related Post