XML Schema Tuto...login
XML Schema Tutorial
author:php.cn  update time:2022-04-20 14:13:02

XML Schema Date/Time Data Type



Date and time data types are used to contain date and time values.


Date Data Type

The date data type is used to define dates.

Dates are defined using this format: "YYYY-MM-DD", where:

  • YYYY represents the year

  • MM represents the month

  • DD represents the number of days

Note:All ingredients are required

The following is an example of date declaration in schema:

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

The elements in the document should look something like this:

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

Time Zone

If required Specify a time zone. You can also enter a date using UTC time by adding a "Z" after the date - for example:

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

Alternatively, you can specify an offset based on the world's adjusted time by adding a positive or negative time after the date - for example:

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

or

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

##h2>Time Data Type (Time Data Type)
The time data type is used to define time.

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

  • hh represents the hour

  • mm means minutes

  • ss means seconds

Note: All ingredients are required!

The following is an example of time declaration in schema:

<xs:element name="start" type="xs:time"/>
The elements in the document should look something like this:

<start>09:00:00</start>
Or something like this:

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

If you need to specify a time zone, you can also specify it by Enter a time using UTC time by adding a "Z" after the time - for example:

<start>09:30:10Z</start>
Alternatively, you can specify the offset based on the world adjustment time by adding a positive or negative time after the time - for example:

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

or

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


DateTime Data Type

DateTime Data Type is used to define date and time.

The date and time are defined using the following format: "YYYY-MM-DDThh:mm:ss", where:

  • YYYY represents the year

  • MM represents the month

  • DD represents the day

  • T represents the beginning of the required time part

  • hh represents hours

  • mm represents minutes

  • ss represents seconds

Note: All ingredients are required!

The following is an example of date and time declaration in schema:

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

The elements in the document should look something like this:

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

Or something like this:

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

Time zone

if needed To specify a time zone, you can also enter a date and time using Universal Adjusted Time (UTC time) by adding a "Z" after the date and time - for example:

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

Alternatively, you can specify an offset based on the world adjustment time by adding a positive or negative time after the time. Amount - For example:

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

or

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


h2>Duration Data Type (Duration Data Type)

Duration data type is used at specified time intervals.

The time interval is specified using the following format: "PnYnMnDTnHnMnS", where:

  • ##P represents the period (required)

  • nY represents the number of years

  • nM represents the number of months

  • nD represents the number of days

  • T represents the time Start of part (required if you plan to specify hours, minutes, and seconds)

  • nH represents the number of hours

  • nM Represents the number of minutes

  • nS Represents the number of seconds

The following is an example of a duration declaration in the schema:

<xs:element name="period" type="xs:duration"/>
The elements in the document should look like this:

<period>P5Y</period>
The above example represents a 5-year cycle.

Or something like this:

<period>P5Y2M10D</period>

The above example represents a 5-year, 2-month and 10-day period.

Or something like this:

<period>P5Y2M10DT15H</period>

The above example represents a period of 5 years, 2 months, 10 day and 15-hour periods.

Or similar to this:

<period>PT15H</period>

The above example represents a 15-hour period.

Negative duration

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

<period>-P10D</ period>

The above example represents a negative 10-day period.


Date and time data types

NameDescription
date Define a date value
dateTimeDefine a date and time value
durationDefine a time interval
gDayDefine a part of a date - day (DD)
gMonth Define a part of the date - month (MM)
gMonthDayDefine a part of the date - month and day (MM-DD)
gYearDefine a part of the date - year (YYYY)
gYearMonthDefine the date A Part - Year and Month (YYYY-MM)
timeDefine a time value


Restriction on date data type (Restriction)

Restrictions that can be used with date data type:

  • enumeration

  • maxExclusive

  • maxInclusive

  • minExclusive

  • minInclusive

  • pattern

  • whiteSpace