YouTip LogoYouTip

Prop Datetime Value

HTML DOM Input Datetime value Property

HTML DOM Input Datetime value Property

HTML DOM Input Datetime value Property

-- Learning is not just about technology, but also about dreams!

JavaScript Reference

Overview

JavaScript Objects

Browser Objects

DOM Objects

HTML Objects

<input> - date

<input> - datetime-local

Deep Dive

  • Programming
  • Software
  • Computer Science
  • Scripting
  • Development Tools
  • Scripting Languages
  • Web Service
  • Web Design and Development
  • Web Services
  • Programming Languages

Input Datetime value Property

Input Datetime Object Reference Input Datetime Object

Example

Set the date and time of 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 property describes the date and time of a datetime field.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the value property.

Note: Internet Explorer, Firefox, Opera 15 (and later) or Chrome support the <input> element with type="datetime".


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 Describes the date and time. Parsed as follows:
  • YYYY - Year (e.g., 2011)
  • MM - Month (e.g., 01 for January)
  • DD - Day (e.g., 08)
  • T - Separator required if time is specified
  • hh - Hours (e.g., 22 for 10.00pm)
  • mm - Minutes (e.g., 55)
  • ss - Seconds (e.g., 03)
  • TZD - Time zone designator (Z indicates 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;

x will output:

2014-02-06T10:57Z

Try it yourself Β»


Related Pages

HTML Reference: HTML <input> value Attribute


Input Datetime Object Reference Input Datetime Object

← Dom Obj Datetime LocalProp Datetime Type β†’