shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
toYyyyMmDd
Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.datetime
This function allows you to pass any date string or Date instance and get back this
one formatted as YYYY-MM-DD.
This format is useful when you need to store dates in a database, set a date input value, etc…
Under the hood, it make uses of the wonderful Luxon library.
Params
- date*-String
The date (string) to convert to `YYYY-MM-DD`
- settings{}TtoYyyyMmDdSettings
Some settings to configure your parsing
Return
- -String
The date formatted as `YYYY-MM-DD`
Example
import { toYyyyMmDd } from '@blackbyte/sugar/datetime';
toYyyyMmDd('2025-10-15T14:30:00+02:00'); // '2025-10-15'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