Parse ISO string
Parse the given string in ISO 8601 format and return an instance of Date.
Function accepts complete ISO 8601 formats as well as partial implementations. ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
If the argument isn't a string, the function cannot parse the string or the values are invalid, it returns Invalid Date.
// CommonJS
var parseISO = require('date-fns/parseISO')
// ES 2015 import parseISO from 'date-fns/parseISO'
// ESM
import { parseISO } from 'date-fns'
parseISO(argument, [options])
| Name | Description |
|---|---|
argument |
the value to convert |
options |
an object with options. |
options.additionalDigits |
the additional number of digits in the extended year format |
| Description |
|---|
|
the parsed date in the local time zone |
| Type | Description |
|---|---|
TypeError |
1 argument required |
RangeError |
|
// Convert string '2014-02-11T11:30:30' to date:
const result = parseISO('2014-02-11T11:30:30')
//=> Tue Feb 11 2014 11:30:30
// Convert string '+02014101' to date,
// if the additional number of digits in the extended year format is 1:
const result = parseISO('+02014101', { additionalDigits: 1 })
//=> Fri Apr 11 2014 00:00:00
© 2021 Sasha Koss and Lesha Koss
Licensed under the MIT License.
https://date-fns.org/v2.29.2/docs/parseISO