Date and time data types are used for values that contain date and time.
The date data type is used to specify a date.
The date is specified in the following form "YYYY-MM-DD" where:
Note: All components are required!
The following is an example of a date declaration in a schema:
An element in your document might look like this:
To specify a time zone, you can either enter a date in UTC time by adding a "Z" behind the date - like this:
or you can specify an offset from the UTC time by adding a positive or negative time behind the date - like this:
The time data type is used to specify a time.
The time is specified in the following form "hh:mm:ss" where:
Note: All components are required!
The following is an example of a time declaration in a schema:
An element in your document might look like this:
Or it might look like this:
To specify a time zone, you can either enter a time in UTC time by adding a "Z" behind the time - like this:
or you can specify an offset from the UTC time by adding a positive or negative time behind the time - like this:
The dateTime data type is used to specify a date and a time.
The dateTime is specified in the following form "YYYY-MM-DDThh:mm:ss" where:
Note: All components are required!
The following is an example of a dateTime declaration in a schema:
An element in your document might look like this:
Or it might look like this:
To specify a time zone, you can either enter a dateTime in UTC time by adding a "Z" behind the time - like this:
or you can specify an offset from the UTC time by adding a positive or negative time behind the time - like this:
The duration data type is used to specify a time interval.
The time interval is specified in the following form "PnYnMnDTnHnMnS" where:
The following is an example of a duration declaration in a schema:
An element in your document might look like this:
The example above indicates a period of five years.
Or it might look like this:
The example above indicates a period of five years, two months, and 10 days.
Or it might look like this:
The example above indicates a period of five years, two months, 10 days, and 15 hours.
Or it might look like this:
The example above indicates a period of 15 hours.
To specify a negative duration, enter a minus sign before the P:
The example above indicates a period of minus 10 days.
| Name | Description |
|---|---|
| date | Defines a date value |
| dateTime | Defines a date and time value |
| duration | Defines a time interval |
| gDay | Defines a part of a date - the day (DD) |
| gMonth | Defines a part of a date - the month (MM) |
| gMonthDay | Defines a part of a date - the month and day (MM-DD) |
| gYear | Defines a part of a date - the year (YYYY) |
| gYearMonth | Defines a part of a date - the year and month (YYYY-MM) |
| time | Defines a time value |
Restrictions that can be used with Date data types:
| WEB HOSTING |
|---|
| Best Web Hosting |
| PHP MySQL Hosting |
| Best Hosting Coupons |
| UK Reseller Hosting |
| Cloud Hosting |
| Top Web Hosting |
| $7.95/mo SEO Hosting |
| Premium Website Design |
| WEB BUILDING |
|---|
| Download XML Editor |
| FREE Website BUILDER |
| Free Website Templates Free CSS Templates |
| Make Your Own Website |
| W3SCHOOLS EXAMS |
|---|
|
Get Certified in: HTML, CSS, JavaScript, XML, PHP, and ASP |
| W3SCHOOLS BOOKS |
|---|
|
New Books: HTML, CSS JavaScript, and Ajax |
| STATISTICS |
|---|
|
Browser Statistics Browser OS Browser Display |
| SHARE THIS PAGE |
|---|