The parse
function applies the interprets its argument as a date and time; it returns a Number, the UTC parse
interprets the resulting StringDate.parse
to return
If the String conforms to the MM
or DD
elements are absent, "01"
is used. When the HH
, mm
, or ss
elements are absent, "00"
is used. When the sss
element is absent, "000"
is used. When the time zone designator is absent, date-only forms are interpreted as a UTC time and date-time forms are interpreted as a local time.
If x
is any Date object whose milliseconds amount is zero within a particular implementation of ECMAScript, then all of the following expressions should produce the same numeric value in that implementation, if all the properties referenced have their initial values:
x.valueOf()
Date.parse(x.toString())
Date.parse(x.toUTCString())
Date.parse(x.toISOString())
However, the expression
Date.parse(x.toLocaleString())
is not required to produce the same Number value as the preceding three expressions and, in general, the value produced by Date.parse
is implementation-dependent when given any String value that does not conform to the Date Time String Format (toString
or toUTCString
method.
When the parse
function is called, the following steps are taken:
.
followed by the first three code units of the "00"
..
followed by the first three 1
.YYYY
format element is present in msInputString.YYYY
format element of msInputString represents a year exceeding the bounds of a MM
format element is present in msInputString and its value is "00"
or its value is greater than "12"
or the combination of the YYYY
and MM
format elements of msInputString represents a year and month exceeding the bounds of a DD
format element is present in msInputString and the combination of the YYYY
, MM
, and DD
format elements of msInputString represents a nonexistent date or a date exceeding the bounds of a YYYY
, MM
, and DD
format elements of msInputString (substituting "01"
for any absent MM
or DD
element) represents a date that is part of the proleptic Gregorian calendar.HH
format element is present in msInputString and its value is greater than "24"
or its value is equal to "24"
and one or more of the mm
, ss
, and sss
format elements are present in msInputString with a value including any code unit other than 0
, return mm
format element is present in msInputString and its value is greater than "59"
, return ss
format element is present in msInputString and its value is greater than "59"
, return HH
, mm
, and ss
format elements of msInputString (substituting "00"
for any absent element) represents either a valid time of day that is at most "23:59:59"
or a special end-of-day "24:00:00"
.Z
format element is present in msInputString and its HH
component is greater than "23"
or its mm
component is greater than "59"
, return Z
format element is either absent from msInputString or represents a UTC offset of magnitude less than 24 hours.Date.prototype.toString
(Date.prototype.toUTCString
(© 2019 Richard Gibson
All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.