HTML DOM Input Datetime name Property

The HTML DOM Input Datetime name property returns a string, which is the value of the name attribute of input datetime. User can also set it to a new string.


Following is the syntax −

  • Returning string value
  • Setting name attribute to a string value = ‘String’


Let us see an example of Input Datetime name property −

 Live Demo

<!DOCTYPE html>
<title>Input Datetime Name</title>
Datetime: <input type="datetime" id="datetime" name="Mother's Birth Day" value="1983-05-13T15:32IST">
<button onclick="changeNameValue()">Change name value</button>
<div id="divDisplay"></div>
   var inputDatetime = document.getElementById("datetime");
   var divDisplay = document.getElementById("divDisplay");
   divDisplay.textContent = 'Name of datetime input: ';
   function changeNameValue() {
      if( == "Mother's Birth Day"){ = "Fathers's Birth Day";
         divDisplay.textContent = 'Name of datetime input: ';


This will produce the following output −

Before clicking ‘Change name value’ button −

After clicking ‘Change Name Value’ button −