Input DatetimeLocal value Property

Input DatetimeLocal Object Reference Input DatetimeLocal Object


Set a local date and time for a datetime field:

document.getElementById("myLocalDate").value = "2014-01-02T11:42:13.510";

Try it yourself »

Definition and Usage

The value property sets or returns the value of the value attribute of a local datetime field.

The value attribute specifies a local date and time for the datetime field.

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The value property is supported in all major browsers.

Note: The <input type="datetime-local"> element is not supported in Internet Explorer or Firefox.


Return the value property:


Set the value property:

Property Values

Value Description Specifies the date and time. Explanation of components:
  • YYYY - year (e.g. 2011)
  • MM - month (e.g. 01 for January)
  • DD - day of the month (e.g. 08)
  • T - a required separator if time is also specified
  • hh - hour (e.g. 22 for 10.00pm)
  • mm - minutes (e.g. 55)
  • ss - seconds (e.g. 03)
  • ms - milliseconds (e.g. 510)

Technical Details

Return Value: A String, representing the date and time of the local datetime field

More Examples


Get the local date and time of a datetime field:

var x = document.getElementById("myLocalDate").value;

The result of x will be:


Try it yourself »


An example that shows the difference between the defaultValue and value property:

var x = document.getElementById("myLocalDate");
var defaultVal = x.defaultValue;
var currentVal = x.value;

Try it yourself »

Related Pages

HTML reference: HTML <input> value attribute

Input DatetimeLocal Object Reference Input DatetimeLocal Object


Color Picker