w3pop.com :: ÍøÂçѧԺ :: Schema (XSD) :: XSD ÈÕÆÚÊý¾ÝÀàÐÍ
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:
ÈÕÆÚÓÉÏÂÃæµÄ"YYYY-MM-DD"ÐÎʽָ¶¨£º
Note: All components are required!
×¢Ò⣺ËùÓÐ×é¼þ¶¼ÊDZØÒª×é¼þ¡£
The following is an example of a date declaration in a schema:
ÏÂÃæÊÇÒ»·ÝÔÚschemaÖÐÉùÃ÷Èͮ򵀡¸Àý£º
<xs:element name="start" type="xs:date"/> |
An element in your document might look like this:
ÔÚÄãµÄÎĵµÖУ¬¿ÉÄܰüº¬ÕâÑùÒ»¸öÔªËØ£º
<start>2002-09-24</start> |
To specify a time zone, you can either enter a date in UTC time by adding a "Z" behind the date - like this:
ΪÁËÖ¸¶¨Ò»¸öʱ¼äÇø£¬Äã¼È¿ÉÒÔͨ¹ýÔÚÈÕÆÚÖ®ºó¼ÓÉÏ "Z" ·ÃÎÊ UTC ʱ¼ä¸ñʽµÄÈÕÆÚ£¬ÈçÏÂËùʾ£º
<start>2002-09-24Z</start> |
or you can specify an offset from the UTC time by adding a positive or negative time behind the date - like this:
Ò²¿ÉÒÔÔÚ UTC ʱ¼äÖ®ºó¼Ó¡¢¼õÒ»¸öʱ¼äÖµ£¬ÈçÏÂËùʾ£º
<start>2002-09-24-06:00</start> or <start>2002-09-24+06:00</start> |
The time data type is used to specify a time.
ʱ¼äÊý¾ÝÀàÐÍÓÃÓÚÖ¸¶¨Ò»¸öʱ¼ä¡£
The time is specified in the following form "hh:mm:ss" where:
ʱ¼äÓÉÏÂÃæµÄ"hh:mm:ss"ÐÎʽָ¶¨£º
Note: All components are required!
×¢Ò⣺ËùÓеÄ×é¼þ¶¼ÊDZØÒª×é¼þ¡£
The following is an example of a time declaration in a schema:
ÏÂÃæÊÇÔÚschemaÄÚÉùÃ÷ʱ¼äµÄ°¸Àý£º
<xs:element name="start" type="xs:time"/> |
An element in your document might look like this:
ÔÚÄãµÄÎĵµÖУ¬¿ÉÄܰüº¬ÏÂÊöÔªËØ£º
<start>09:00:00</start> |
Or it might look like this:
»òÕßÊÇÕâÑùµÄ£º
<start>09:30:10.5</start> |
To specify a time zone, you can either enter a time in UTC time by adding a "Z" behind the time - like this:
ΪÁËÖ¸¶¨Ò»¸öʱ¼äÇø£¬Äã¼È¿ÉÒÔͨ¹ýÔÚʱ¼äÖ®ºó¼ÓÉÏ "Z" ·ÃÎÊ UTC ʱ¼ä¸ñʽµÄÈÕÆÚ£¬ÈçÏÂËùʾ£º
<start>09:30:10Z</start> |
or you can specify an offset from the UTC time by adding a positive or negative time behind the time - like this:
Ò²¿ÉÒÔUTCʱ¼äºó¼Ó¡¢¼õÒ»¸öʱ¼äÖµ£¬ÈçÏÂËùʾ£º
<start>09:30:10-06:00</start> or <start>09:30:10+06:00</start> |
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:
ÈÕÆÚʱ¼äÓÉ"YYYY-MM-DDThh:mm:ss"µÄÐÎʽָ¶¨£º
Note: All components are required!
×¢Ò⣺ËùÓÐ×é¼þ¶¼ÊDZØÒª×é¼þ¡£
The following is an example of a dateTime declaration in a schema:
ÏÂÃæÁоÙÁËschemaÄÚµÄÈÕÆÚʱ¼äÉùÃ÷µÄ°¸Àý£º
<xs:element name="startdate" type="xs:dateTime"/> |
An element in your document might look like this:
ÔÚÄãµÄÎĵµÖУ¬»òÐí°üº¬ÁËÏÂÊöÔªËØ£º
<startdate>2002-05-30T09:00:00</startdate> |
Or it might look like this:
»òÕßÊÇÕâÑùµÄ£º
<startdate>2002-05-30T09:30:10.5</startdate> |
To specify a time zone, you can either enter a dateTime in UTC time by adding a "Z" behind the time - like this:
Ϊָ¶¨Ò»¸öʱ¼äÇø£¬Äã¼È¿ÉÒÔͨ¹ýÔÚʱ¼äµÄºóÃæ¼Ó¸ö "Z" ·ÃÎÊ UTC ʱ¼ä¸ñʽµÄÈÕÆÚ£¬ÈçÏÂËùʾ£º
<startdate>2002-05-30T09:30:10Z</startdate> |
or you can specify an offset from the UTC time by adding a positive or negative time behind the time - like this:
Ò²¿ÉÒÔUTCʱ¼äºó¼Ó¡¢¼õÒ»¸öʱ¼äÖµ£¬ÈçÏÂËùʾ£º
<startdate>2002-05-30T09:30:10-06:00</startdate> or <startdate>2002-05-30T09:30:10+06:00</startdate> |
The duration data type is used to specify a time interval.
³ÖÐøÊ±¼äÊý¾ÝÀàÐÍ£¨»ò“ʱ¼ä¶ÎÊý¾ÝÀàÐÍ”£©ÓÃÓÚ¶¨ÒåÒ»¶Îʱ¼ä¼ä¸ô¡£
The time interval is specified in the following form "PnYnMnDTnHnMnS" where:
ʱ¼ä¼ä¸ôÊÇÓÉ"PnYnMnDTnHnMnS"ÐÎʽ¶¨ÒåµÄ£¬½âÊÍÈçÏ£º
The following is an example of a duration declaration in a schema:
ÏÂÃæÊÇschemaÄÚµÄʱ¼ä¶ÎÉùÃ÷µÄ°¸Àý£º
<xs:element name="period" type="xs:duration"/> |
An element in your document might look like this:
ÔÚÄãµÄÎĵµÖлòÐí°üº¬ÏÂÊöÔªËØ£º
<period>P5Y</period> |
The example above indicates a period of five years.
ÉÏÊö°¸ÀýÖ¸¶¨ÁË5ÄêµÄʱ¼ä¶Î£º
Or it might look like this:
»òÕßÒ²¿ÉÒÔÏñÕâÑù£º
<period>P5Y2M10D</period> |
The example above indicates a period of five years, two months, and 10 days.
ÉÏÊö°¸ÀýÖ¸¶¨ÁË5Äê2¸öÔÂÁã10ÌìµÄʱ¼ä¶Î¡£
Or it might look like this:
ËüÒ²¿ÉÒÔÊÇÕâÑù£º
<period>P5Y2M10DT15H</period> |
The example above indicates a period of five years, two months, 10 days, and 15 hours.
ÉÏÊö°¸ÀýÖ¸¶¨ÁË5Äê2¸öÔÂÁã10ÌìÓÖ15¸öСʱµÄʱ¼ä¶Î¡£
Or it might look like this:
»òÕßËü¿ÉÒÔÊÇÕâÑù£º
<period>PT15H</period> |
The example above indicates a period of 15 hours.
ÉÏÊö°¸ÀýÖ¸¶¨ÁË15¸öСʱµÄʱ¼ä¶Î¡£
To specify a negative duration, enter a minus sign before the P:
Èç¹ûÒª¶¨Ò帺ʱ¼ä¶Î£¬ÄǾÍÐèÒªÔÚP֮ǰÌí¼ÓÒ»¸ö¸ººÅ£º
<period>-P10D</period> |
The example above indicates a period of minus 10 days.
ÉÏÊö°¸ÀýÖ¸¶¨Á˸º10ÌìµÄʱ¼ä¶Î¡£
| 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) ¶¨ÒåÈÕÆÚµÄÒ»²¿·Ö——ÈÕ£ºday (DD) |
| gMonth | Defines a part of a date - the month (MM) ¶¨ÒåÈÕÆÚµÄÒ»²¿·Ö——Ô£ºmonth (MM) |
| gMonthDay | Defines a part of a date - the month and day (MM-DD) ¶¨ÒåÈÕÆÚµÄÒ»²¿·Ö——ÔºÍÈÕ£ºmonth and day (MM-DD) |
| gYear | Defines a part of a date - the year (YYYY) ¶¨ÒåÈÕÆÚµÄÒ»²¿·Ö—— Ä꣺year (YYYY) |
| gYearMonth | Defines a part of a date - the year and month (YYYY-MM) ¶¨ÒåÁËÈÕÆÚµÄÒ»²¿·Ö—— ÄêºÍÔ£º year and month (YYYY-MM) |
| time | Defines a time value ¶¨Òåʱ¼äÖµ |
Restrictions that can be used with Date data types:
¿ÉÔ¼ÊøµÄÈÕÆÚÊý¾ÝÀàÐÍÈçÏÂËùʾ£º
ÆÀÂÛ (0)
All