I want to store the value of dates in a variable which user selects without using form.I am able to fetch date using javascript but for my application i need to store them in php variables.
 <html>
    <head>
    <script>
function myFunction() {
    var x = document.getElementById("date1").value;
    document.getElementById("demo").innerHTML = x;
    var y = document.getElementById("date2").value;
    document.getElementById("demo1").innerHTML = y;
}
    </script>
    </head>
    <body>
    <?php
            echo '<button onclick="myFunction()">Try it</button>';
            echo '<input type="date" name="date1" >';
            echo ' ';
            echo '<label>'."Date2:".'</label>';
            echo '<input type="date" name="date1">';
            echo '<p id="demo"></p>';
            echo '<p id="demo1"></p>';  
    ?>
    </body>
    </html>
 
     
    