Description
Is your feature request related to a problem? Please describe.
@wordpress/date
, powered by Moment.js under the hood, is a neat and simple way to format dates. However, what currently is missing is a way to display relative times like human_time_diff()
does in PHP.
Describe the solution you'd like
Moment.js has a function called fromNow()
(docs) that allows you to display relative times like "4 years ago" or "44 seconds ago", and a similar from()
function to display a moment in relation to a time other than now.
A new function similar to human_time_diff()
could be added to the package that makes use of these functions.
Happy to work on a PR to add this kind of functionality.
Describe alternatives you've considered
Alternatives would be using Moment.js directly and not via @wordpress/date
, or using a dedicated library like timeago.js
Activity