<!DOCTYPE html> <html lang="en"> <head> <title>HTML5 Datetime-local Input Type</title> <script> function getValue() { var datetime = document.getElementById("datetime").value; alert(datetime); } </script> </head> <body> <form> <label for="mydatetime">Choose the Date and Time:</label> <input type="datetime-local" id="datetime"> <button type="button" onclick="getValue();"> Value</button> </form> </body> </html>