Reputation: 15
i want two input in html code and one of them set on form load and other one set on mousedown event when i click on submit button time must be different in each of input problem : but each of inputs have same date and time
test2.php
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<script>
function SetTimeToEndInput() {
document.getElementById("End").setAttribute("value","<?php date_default_timezone_set('Asia/Tehran'); $t=time(); echo date("Y-m-d h:i:s");?>");
}
</script>
</head>
<body>
<form class="" action="test3.php" method="post">
<input type="text" name="Start" value="<?php date_default_timezone_set('Asia/Tehran'); $t=time();echo date("Y-m-d h:i:s") ?>">
<input id="End" type="text" name="End" value="">
<input type="submit" name="" value="" onmousedown="SetTimeToEndInput()">
</form>
</body>
</html>
test3.php
<?php
if (isset($_POST['submit'])) {
echo $_POST['Start'];
echo $_POST['End'];
}
?>
result is '2023-01-27 09:19:04', '2023-01-27 09:19:04'
Upvotes: 0
Views: 24