import { parse } from "https://dotland.deno.dev/std@0.224.0/datetime/parse.ts";
Parses a date string using the specified format string.
The following symbols from unicode LDML are supported:
yyyy
- numeric yearyy
- 2-digit yearM
- numeric monthMM
- 2-digit monthd
- numeric daydd
- 2-digit dayH
- numeric hour (0-23 hours)HH
- 2-digit hour (00-23 hours)h
- numeric hour (1-12 hours)hh
- 2-digit hour (01-12 hours)m
- numeric minutemm
- 2-digit minutes
- numeric secondss
- 2-digit secondS
- 1-digit fractional secondSS
- 2-digit fractional secondSSS
- 3-digit fractional seconda
- dayPeriod, eitherAM
orPM
'foo'
- quoted literal./-
- unquoted literal
Examples
Basic usage
Basic usage
import { parse } from "https://deno.land/std@0.224.0/datetime/parse.ts";
parse("20-01-2019", "dd-MM-yyyy"); // 2019-01-19T13:00:00.000Z
parse("01-20-2019 04:34 PM", "MM-dd-yyyy hh:mm a"); // 2019-01-20T05:34:00.000Z
parse("01-20-2019 16:34:23.123", "MM-dd-yyyy HH:mm:ss.SSS"); // 2019-01-20T05:34:23.123Z