shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
parseDate
Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.datetime
This function allows you to parse a date string. It will returns the Date instance for this date.
Under the hood, it make uses of the wonderful Luxon library.
Make sure to use the library if you need more control over your dates.
Luxon support these date formats:
- ISO 8601
- RFC2822
- HTTP (header)
Params
- date*-String
The date string to parse
- settings{}TParseDateSettings
Some settings to configure your parsing
Return
- -Date
The `Date` instance representing your date string
Example
import { parseDate } from '@blackbyte/sugar/datetime';
parseDate('2025-10-12');
parseDate('2024-10-15T10:30:00Z');Settings
- format”String
If you know the format of your date string, you can pass it here. This will make the parsing faster and more reliable. See Luxon documentation for the list of supported tokens.
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space