Date.diffHuman
$date.diffHuman($fromDate='now') -> string
Description
Return a human-readable string that contains the difference between this date and $fromDate.
It always includes a positive whole number.
RoundingThis method makes human-friendly approximations. It rounds up remainders above 0.9 (e.g. 11 months = 1 year.) and rounds larger numbers to multiples of 5 or 10 (e.g. 26 seconds = 30 seconds).
$now = Date.now()
$otherDate = $now.add(50, 'hours')
$otherDate.diffHuman()
//= '2 days'
$almostMinute = $now.add(58, 'seconds')
$almostMinute.diffHuman()
//= '1 minute'
$longAgo = $now.add(-1000, 'days')
$longAgo.diffHuman()
//= '3 years'
$date1 = Date.create('50 days')
$date2 = Date.create('300 days ago')
$date1.diffHuman($date2)
//= '1 year'