Date and time data types are used for values that contain date and time.
日期和时间数据类型(Date and time data types)用于定义日期和时间数据的。
Date Data Type
日期数据类型
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"形式指定。
- YYYY indicates the year
YYYY指示年份 - MM indicates the month
MM指示月份 - DD indicates the day
DD 指示日期
Note: All components are required!
注意:所有组件都是必需的。
The following is an example of a date declaration in a schema:
下面是schema(XML公式)里的声明日期的例子
<xs:element name="start" type="xs:date"/> |
An element in your document might look like this:
你文档中的某个元素也许是这样的:
<start>2002-09-24</start> |
Time Zones
时间区
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> |
Time Data Type
时间数据类型
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"形式指定:
- hh indicates the hour
hh指示小时 - mm indicates the minute
mm 指示分钟 - ss indicates the second
ss指示秒钟
Note: All components are required!
注意:所有的组件都是必需的
The following is an example of a time declaration in a schema:
下面是schema(XML公式)里的时间声明的例子
<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> |
Time Zones
时间区
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> |
DateTime Data Type
日期时间数据类型(DateTime Data Type)
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"的形式指定:
- YYYY indicates the year
YYYY指示时间 - MM indicates the month
MM指示月份 - DD indicates the day
DD 指示时间 - T indicates the start of the required time section
T指示时间区的开头 - hh indicates the hour
hh指示小时 - mm indicates the minute
mm指示分钟 - ss indicates the second
ss指示秒钟
Note: All components are required!
注意:所有组件都是必需的
The following is an example of a dateTime declaration in a schema:
下面是schema(XML公式)里的日期时间声明的例子
<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> |
Time Zones
时间区
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> |
Duration Data Type
持续时间数据类型(或“时间段数据类型”)(Duration Data Type)
The duration data type is used to specify a time interval.
持续时间数据类型(或“时间段数据类型”)用于定义一段时间间隔
The time interval is specified in the following form "PnYnMnDTnHnMnS" where:
时间间隔由"PnYnMnDTnHnMnS"形式定义的
- P indicates the period (required)
P指示 - nY indicates the number of years
nY指示年数 - nM indicates the number of months
nM指示月数 - nD indicates the number of days
nD指示天数 - T indicates the start of a time section (required if you are going to specify hours, minutes, or seconds)
T指示时间部分的开头(如果你要指定时间,分钟,或秒数,就必须用到T) - nH indicates the number of hours
nH指示小时数 - nM indicates the number of minutes
nM指示分钟数 - nS indicates the number of seconds
nS指示秒数
The following is an example of a duration declaration in a schema:
下面是schema(XML公式)里的时间段声明的例子
<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天的时间段
Or it might look like this:
或者它会是可以这样:
<period>PT15H</period> |
The example above indicates a period of 15 hours.
上面的例子指出了15小时的时间段
Negative Duration
负时间段
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天的时间段
Date and Time Data Types
日期和时间数据类型
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) 定义了日期的部分定义了时间的一部分——日部分(DD) |
gMonth | Defines a part of a date - the month (MM) 定义了日期的一部分——月部分(MM) |
gMonthDay | Defines a part of a date - the month and day (MM-DD) 定义了日期的一部分——月和日部分(MM-DD) |
gYear | Defines a part of a date - the year (YYYY) 定义了日期的年部分(YYYY) |
gYearMonth | Defines a part of a date - the year and month (YYYY-MM) 定义了日期的一部分——年和月部分(YYYY-MM) |
time | Defines a time value 定义时间值 |
Restrictions on Date Data Types
对日期数据类型的约束
Restrictions that can be used with Date data types:
对日期数据类型可进行约束
- enumeration
列举 - maxExclusive
除去最大值 - maxInclusive
包括最大值 - minExclusive
除去最小值排外 - minInclusive
包括最小值 - pattern
式样 - whiteSpace
空白