Luxon interval human readable
Duration haven't any analogues of humanize()
method, so you should use a third-party library. For example, humanize-duration
, with multilanguage support.
const DateTime = luxon.DateTime;
const Interval = luxon.Interval;
const start = DateTime.fromSQL("2020-06-19 11:14:00");
const finish = DateTime.fromSQL("2020-06-21 13:11:00");
const formatted = Interval
.fromDateTimes(start, finish)
.toDuration()
.valueOf();
console.log(humanizeDuration(formatted))
console.log(humanizeDuration(formatted, { language: 'es' }))
console.log(humanizeDuration(formatted, { language: 'ru' }))
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/global/luxon.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/humanize-duration.min.js"></script>