DateTime
Last updated
Last updated
Internet Object DateTime is inspired by the ISO 8601 format. DateTime can be passed as a string and is represented in the following ways, with or without separators.
Date Time format with separator: YYYY-MM-DDThh:mm:ss.SSSZ
Example : 1997-07-16T19:20:30.500+01:00
Date Time format without separator: YYYYMMDDThhmmss.SSSZ
Example: 19970716T192030.500+0100
The DateTime is the string type and therefore there is no need to enclose it in the double quotation mark (" U+0022)
as parser identifies it as a string.
Here, T
is a delimiter used to separate the date
from the time
. The time
portion in the DateTime
object must be preceded by T
. Z
represents the time zone designator (+hh:mm
or -hh:mm
).
Symbol
Represents
Range
Default Value
YYYY
Year
1990, 1991...
-
MM
Date
01, 02 ... 11, 12
01
DD
Month
01, 02 ... 30, 31
01
HH
Hour
00, 01 ... 22, 23
00
mm
Minute
00, 01 ... 58, 59
00
ss
Second
00, 01 ... 58, 59
00
SSS
Millisecond
000, 001 ... 998, 999
000
The Year field must be provided as it does not have any default value.
Symbol
Character
Unicode
Description
-
Hyphen
U+002D
Used to separate parts of the date
:
Colon
U+003A
Used to different parts of time
.
Period
U+002E
Used to separate seconds from milliseconds
T
Alphabet "T"
U+0054
DateTime separator
The Date must be complete such as YYYY-MM-DD or YYYYMMDD before providing the time.
The Time Zone can be represented as ±hh: mm
or ±hhmm
i.e with or without separators. For example, +00:00
, +0000
or +00
. However, representing -00:00
, -0000
, or -00
is not permitted. While representing a Time Zone, a plus sign must be used for positive zero values and a minus sign for negative values.
Time Zone is written at the end of a DateTime. It is not a separate data type on its own. It can only be passed when both date and time are passed to a DateTime object. "Z"
can be directly added after time without space, where "Z"
is the zone designator for the zero UTC offset. It defaults to Z or Zulu Time or Greenwich mean time (GMT) or +0:00
.
Time Zone with separators:
Time Zone without Separators:
+HH:mm
= +05:30
+HHmm
= +0530
+HH
= +05
+HH
= +05
-HH:mm
= -12:30
-HHmm
= -1230
-HH
= -12
-HH
= -12
Valid date-time representation with separator separating date, time, and time-zone
Valid date-time representation without separator separating date, time, and time-zone.
Defining date time in the Internet Object Document.
Defining date time with timezone in the Internet object Document.
The date and time must be complete such as YYYY-MM-DDTHH:mm:ss.SSS or YYYYMMDDTHHmmssSSS before providing timezone.
The DateTime is derived from the String type, hence it shares the same MemberDef as the String. However, DateTime enforces additional constraints with the respective Datetime format and the same is applicable to the DateTime MemberDef.