I want to "save" the value of into a php variable, so if in the "datebox" there is something like 11/02/2016, I want to save this value on $date, then I can do echo $date; and see again 11/02/2016.
the datepicker is important
I tried on two ways:
1.
<head>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<!-- Today date -->
<input type="date" name="today" value="<?php echo date("Y-m-d");?>">
</form>
</body>
<?php
$date = date('Y-m-d', strtotime($_POST['today']));
echo "Today is $date";
?>
This output: Today is 1970-01-01
2.
<head>
<script>
function myFunction() {
var date = document.getElementById("today").value;
document.getElementById("here").innerHTML = date;
}
</script>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<input type="date" name="today" value="<?php echo date("Y-m-d");?>">
<input type="hidden" id="here" name="this">
</form>
</body>
<?php
$data = $_POST['this']));
echo "Today is $data";
?>
This output: Today is
Can anybody help me please?
Thanks in advance.
time(), which means you're generating a "now" date, always.