shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
diffBetweenDates
Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.datetime
This function allows you to get the difference between two date strings. It will returns you an object with the difference represented with these properties (years, months, days, hours, minutes, seconds). Under the hood, it make uses of the wonderful Luxon library.
Params
- date*-String
The date string to parse
- settings{}TDiffBetweenDatesSettings
Some settings to configure your parsing
Return
- -Date
The `Date` instance representing your date string
Example
import { diffBetweenDates } from '@blackbyte/sugar/datetime';
diffBetweenDates('1945-10-12', '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