Description
This function calculates the difference between two dates in the specified unit. The unit can be one of the following: "days", "hours", "months", "years", "minutes", "seconds", or "milliseconds". The inputLocale option allows you to specify the locale of the input dates, with the following options: "pt", "nl", "en", "de", "ja", "zh", or "fr".
Parameters
- date1: (string) The first date to compare.
- date2: (string) The second date to compare.
- unit: (optional, string) The unit in which to calculate the difference. Default is "days".
- inputLocale: (optional, string) The locale of the input dates. Default is "en".
Examples
diff-dates("2020-01-01", "2020-01-02", unit="days") // Output: 1
diff-dates("2020-01-01 12:00:00", "2020-01-01 12:01:00", unit="minutes") // Output: 1
diff-dates("Jan 1, 2020", "Jan 2, 2020", unit="days", inputLocale="en") // Output: 1
diff-dates("01/01/2020", "02/01/2020", unit="days", inputLocale="pt") // Output: 1