Latest web development tutorials

XML Schema date / time data types

Date and time data types for values ​​that contain the date and time.


Date data type (Date Data Type)

Date data type is used to define the date.

Date This format is defined: "YYYY-MM-DD", where:

  • YYYY indicates the year
  • MM is the month
  • DD represents the number of days

Note: All components are required

The following is a statement about the schema date examples:

<xs:element name="start" type="xs:date"/>

Elements in the document should look like this:

<start>2002-09-24</start>

Time zone

To specify a time zone, you can also add a date in the "Z" way, using the world time (UTC time) to enter a date - like this:

<start>2002-09-24Z</start>

Or such later date as may be by adding a positive or negative time methods to adjust the provisions to the world based on the time offset - like this:

<start>2002-09-24-06:00</start>

或者

<start>2002-09-24+06:00</start>


h2> Time Data Types (Time Data Type)

Time data type is used to define the time.

Time is defined using the following format: "hh: mm: ss", which

  • hh is the hour
  • mm is the minute
  • ss represents seconds

Note: All components are required!

Here is an example of a time in the relevant schema declaration:

<xs:element name="start" type="xs:time"/>

Elements in the document should look like this:

<start>09:00:00</start>

Or like this:

<start>09:30:10.5</start>

Time zone

To specify a time zone, you can also add in time after a "Z" way, using the world time (UTC time) to enter a time - like this:

<start>09:30:10Z</start>

Or can be created after the time to add a positive or negative time methods to adjust the provisions to the world based on the time offset - like this:

<start>09:30:10-06:00</start>

or

<start>09:30:10+06:00</start>


Date Time data type (DateTime Data Type)

Datetime data type is used to define the date and time.

Date and time using the following format definition: "YYYY-MM-DDThh: mm: ss", where:

  • YYYY indicates the year
  • MM is the month
  • DD is the day
  • T indicates the start time necessary portion
  • hh is the hour
  • mm is the minute
  • ss represents seconds

Note: All components are required!

Here is an example of a schema related to the date and time stated:

<xs:element name="startdate" type="xs:dateTime"/>

Elements in the document should look like this:

<startdate>2002-05-30T09:00:00</startdate>

Or like this:

<startdate>2002-05-30T09:30:10.5</startdate>

Time zone

To specify a time zone, you can also add a date and time in the "Z" way, using the world time (UTC time) to enter a date and time - like this:

<startdate>2002-05-30T09:30:10Z</startdate>

Or can be created after the time to add a positive or negative time methods to adjust the provisions to the world based on the time offset - like this:

<startdate>2002-05-30T09:30:10-06:00</startdate>

或者

<startdate>2002-05-30T09:30:10+06:00</startdate>


h2> duration data types (Duration Data Type)

Data type for the duration of a predetermined time interval.

Interval using the following format to specify: "PnYnMnDTnHnMnS", in which:

  • P represents the cycle (required)
  • nY represents the number of years
  • nM indicates the number of months
  • nD represents the number of days
  • T represents the time portion of the initial (if you plan specified hours, minutes and seconds, this option is required)
  • nH indicates the number of hours
  • nM the number of minutes
  • nS the number of seconds

Here is an example of a schema related to the duration of the declaration:

<xs:element name="period" type="xs:duration"/>

Elements in the document should look like this:

<period>P5Y</period>

The above example shows a five-year period.

Or like this:

<period>P5Y2M10D</period>

The above example shows a 5 years, 2 months and 10 days cycle.

Or like this:

<period>P5Y2M10DT15H</period>

The above example shows a 5 years, 2 months, 10 days and 15 hours period.

Or like this:

<period>PT15H</period>

The above example shows a 15 hours period.

Negative duration

To specify a negative duration, enter a minus sign before the P:

<period>-P10D</period>

The above example shows a negative 10-day cycle.


Date and time data types

name description
date Define a date value
dateTime Define a date and time value
duration Defines a time interval
gDay A part of the definition of a date - the day (DD)
gMonth A part of the definition of a date - the month (MM)
gMonthDay A part of the definition of a date - the month and day (MM-DD)
gYear A part of the definition of a date - Year (YYYY)
gYearMonth A part of the definition of a date - the year and month (YYYY-MM)
time Define a time value


Date data type defined (Restriction)

Can be used in conjunction with the date data type is defined:

  • enumeration
  • maxExclusive
  • maxInclusive
  • minExclusive
  • minInclusive
  • pattern
  • whiteSpace