<body>
<?php
$t1= $_POST['t1'];
$t2= $_POST['t2'];
$datetime1 = new DateTime($t1);//start time
$datetime2 = new DateTime($t2);//end time
$interval = $datetime1->diff($datetime2);
echo $interval->format('%Y years %m months %d days %H hours %i minutes %s seconds');//00 years 0 months 0 days 08 hours 0 minutes 0 seconds
// put your code here
?>
<input type="time" name="t1">
<input type="time" name="t2">
</body>
Warning: Undefined array key "t1" in D:\xampp\htdocs\ITC\index.php on line 14
Warning: Undefined array key "t2" in D:\xampp\htdocs\ITC\index.php on line 15 00 years 0 months 0 days 00 hours 0 minutes 0 seconds
答案 0 :(得分:0)
使用 method="post" 将两个元素放在一个表单中
像这样:
<form method="post" action="">
<input type="time" name="t1">
<input type="time" name="t2">
</form>