1
Good,
I’m new here and also in the programming language :)
I’m developing a Production per hour calculator in PHP. I was part of the code, I can feed the input and do the calculation, but the result does not come out in HOURS format (00:00:00), I could not convert the value, I want to be filled in the ":" automatically.
I need to add the time between two times.
Example: Start: 07:00:00 - End: 12:00:00 - Total: 05:00:00.
Thanks in advance.
Below is my code. But here is not coming out the result.
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8"/>
<link rel="stylesheet" href="_css/estilo.css"/>
<title>Controle de produção</title>
</head>
<body>
<div>
<form method="post" action="index.php">
<class>Início</class> <class>Fim</class> <class>Horas Trab.</class><br/>
<input type="datatime" placeholder="inicio 1" name="i1"/>
<input type="datatime" placeholder="fim 1" name="f1"/><br/>
<input type="datatime" placeholder="inicio 2" name="i2"/>
<input type="datatime" placeholder="fim 2" name="f2"/><br/>
<input type="submit" value="Calcular produção"/>
</form>
<?php
$inicio1 = isset($_POST["i1"])?$_POST["i1"]:'00:00:00';
$inicio2 = isset($_POST["i2"])?$_POST["i2"]:0;
$fim1 = isset($_POST["f1"])?$_POST["f1"]:0;
$fim2 = isset($_POST["f2"])?$_POST["f2"]:0;
$rht1 = ($fim1 - $inicio1);
$rht2 = ($fim2 - $inicio2);
echo "$rht1 e $rht2";
?>
</div>
</body>
</html>
You need to use
date
take a look at the documentation... https://www.php.net/manual/en/function.date.php– Lodi
As I said, I’m learning programming, and I still can’t read the documentation, :), With the one who sent me I started to understand how the reading works, but if you have any tips, I will be grateful. I thank you for your attention and help ;), and also thank you to all who answered me.
– Marcelo Junges