You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to format the relative dates in short/narrow style. I am using 5.x version, cannot currently upgrade since we have other breaking changes.
Below is my current code:
let formattedDate = intl.formatRelative(date, {
timeZone: userTimezone
});
The above gives in format "2 months ago" / "3 years ago" etc. Instead I am looking for "2 mo. ago" / "3 yrs ago" etc. Documentation says its not supported directly, but suggests the below.
https://ember-intl.github.io/ember-intl/versions/v5.7.0/docs/helpers/format-relative By default, the relative time is computed to the best fit unit, but you can explicitly call it to force units to be displayed in "second", "second-short", "minute", "minute-short", "hour", "hour-short", "day", "day-short", "month", "month-short", "year" or "year-short"
I tried the above suggestion by specifying the units, but that didn't help or I did it wrong. Could anyone provide any suggestion to format in narrow/short format in 5.x? ("2 mo. ago" / "3 yrs ago"" etc)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to format the relative dates in short/narrow style. I am using 5.x version, cannot currently upgrade since we have other breaking changes.
Below is my current code:
The above gives in format "2 months ago" / "3 years ago" etc. Instead I am looking for "2 mo. ago" / "3 yrs ago" etc. Documentation says its not supported directly, but suggests the below.
https://ember-intl.github.io/ember-intl/versions/v5.7.0/docs/helpers/format-relative
By default, the relative time is computed to the best fit unit, but you can explicitly call it to force units to be displayed in "second", "second-short", "minute", "minute-short", "hour", "hour-short", "day", "day-short", "month", "month-short", "year" or "year-short"
I tried the above suggestion by specifying the units, but that didn't help or I did it wrong. Could anyone provide any suggestion to format in narrow/short format in 5.x? ("2 mo. ago" / "3 yrs ago"" etc)
Beta Was this translation helpful? Give feedback.
All reactions