date_parse(format, value)
date_parse(format, value)
will try to parse value
using format
.
If succeeding, it returns the date (and time) as a string that is in the format of %Y-m-%dT%H:%M:%s.%fZ
e.g. 2020-01-01T12:32:32.000Z
.
If failing, it returns null
.
#
Example 1returns:
time |
---|
2020-01-01T12:32:48.000Z |
#
Example 2returns
time |
---|
2020-01-01T19:32:00.000Z |
#
Example 3returns
time |
---|
2020-01-01 |
#
Example 4returns
time |
---|
2019-07-03 |
#
SpecifiersA specifier can be used to parse a specific part of date/time. Here is the list:
Specifier | Example | Description |
---|---|---|
%Y | 2015 | The full proleptic Gregorian year, zero-padded to 4 digits. |
%C | 20 | The proleptic Gregorian year divided by 100, zero-padded to 2 digits. |
%y | 15 | The proleptic Gregorian year modulo 100, zero-padded to 2 digits. |
%m | 07 | Month number (01--12), zero-padded to 2 digits. |
%b | Jun | Abbreviated month name. Always 3 letters. |
%B | February | Full month name. |
%d | 09 | Day number (01--31), zero-padded to 2 digits. |
%e | 9 | Same as %d but space-padded. |
%a | Sun | Abbreviated weekday name. Always 3 letters. |
%A | Sunday | Full weekday name. |
%w | 1 | Sunday = 0, Monday = 1, ..., Saturday = 6. |
%u | 7 | Monday = 1, Tuesday = 2, ..., Sunday = 7. |
%U | 28 | Week number starting with Sunday (00--53), zero-padded to 2 digits. |
%W | 27 | Same as %U , but week 1 starts with the first Monday in that year instead. |
%G | 2015 | Same as %Y but uses the year number in ISO 8601 week date. |
%g | 01 | Same as %y but uses the year number in ISO 8601 week date. |
%V | 27 | Same as %U but uses the week number in ISO 8601 week date (01--53). |
%j | 188 | Day of the year (001--366), zero-padded to 3 digits. |
%D | 03/07/15 | Month-day-year format. Same as %m/%d/%y . |
%F | 2015-07-03 | Year-month-day format (ISO 8601). Same as %Y-%m-%d . |
%v | 3-Jul-2015 | Day-month-year format. Same as %e-%b-%Y . |
%H | 21 | Hour number (00--23), zero-padded to 2 digits. |
%k | 5 | Same as %H but space-padded. |
%I | 07 | Hour number in 12-hour clocks (01--12), zero-padded to 2 digits. |
%l | 7 | Same as %I but space-padded. |
%P | am | am or pm in 12-hour clocks. |
%p | AM | AM or PM in 12-hour clocks. |
%M | 34 | Minute number (00--59), zero-padded to 2 digits. |
%S | 43 | Second number (00--60), zero-padded to 2 digits. |
%f | 0325 | The fractional seconds (in nanoseconds) since last whole second. |
%.f | .0325 | Similar to .%f but left-aligned. These all consume the leading dot. |
%R | 01:35 | Hour-minute format. Same as %H:%M . |
%T | 01:35:17 | Hour-minute-second format. Same as %H:%M:%S . |
%r | 09:35:17 AM | Hour-minute-second format in 12-hour clocks. Same as %I:%M:%S %p . |
%Z | PST | Local time zone name. Skips all non-whitespace characters during parsing. |
%z | -0700 | Offset from the local time to UTC (with UTC being +0000 ). |
%:z | -07:00 | Same as %z but with a colon. |
%#z | -07 | Same as %z but allows minutes to be missing or present. |
%+ | 2015-07-02T07:35:17.036490-07:00 | ISO 8601 / RFC 3339 date & time format. |
%s | 1625801245 | UNIX timestamp, the number of seconds since 1970-01-01 00:00 UTC. |
Please note that Superintendent follows the specifiers offered by the Rust's crate: chrono.