Parses a date based on the locale and options.
parseDate(value, options?)
value - string - Date string to be parsed
options? - object - Parsing options
import { useGlobalize } from 'react-native-globalize';
const ExampleComponent = () => {
const { parseDate } = useGlobalize();
parseDate('1/1/2020', { skeleton: 'yMd' });
// Date(2020, 0, 1)
};
Note: Specify one of date, datetime, skeleton, or time.
| Type |
Required |
Default |
Description |
| string |
No |
none |
Shorthand date-only parsing specification. Possible values: full, long, medium, short. |
parseDate('January 1, 2020', { date: 'long' });
// Date(2020, 0, 1)
| Type |
Required |
Default |
Description |
| string |
No |
none |
Shorthand date and time parsing specification. Possible values: full, long, medium, short. |
parseDate('1/1/20, 12:00 AM', { datetime: 'short' });
// Date(2020, 0, 1)
| Type |
Required |
Default |
Description |
| string |
No |
none |
Flexible parsing mechanism using a pattern with fields in canonical order. See list of skeleton patterns (not all options supported). |
parseDate('Jan 1, 2020, 12:00 AM', { skeleton: 'yMMMdhm' });
// Date(2020, 0, 1)
| Type |
Required |
Default |
Description |
| string |
No |
none |
Shorthand time-only parsing specification. Possible values: full, long, medium, short. |
parseDate('12:00 AM', { time: 'full' });
// Date(today @ 00:00:00)