X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Input Datetime value Property

Input Datetime Object Reference Input Datetime Object

Example

Set a date and time for a datetime field:

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

Try it yourself »


Definition and Usage

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

The value attribute specifies a 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"> element is not supported in Internet Explorer, Firefox, Opera version 15 (and newer) or Chrome.


Syntax

Return the value property:

datetimeObject.value

Set the value property:

datetimeObject.value=YYYY-MM-DDThh:mm:ssTZD

Property Values

Value Description
YYYY-MM-DDThh:mm:ssTZD Specifies the date and/or 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)
  • TZD - Time Zone Designator (Z denotes Zulu, also known as Greenwich Mean Time)

Technical Details

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


More Examples

Example

Get the date and time of a datetime field:

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

The result of x will be:

2014-02-06T10:57Z

Try it yourself »


Related Pages

HTML reference: HTML <input> value attribute


Input Datetime Object Reference Input Datetime Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook