| 1 |
import {humanTimeDiff, getDate} from '@wordpress/date'; |
| 2 |
|
| 3 |
/** |
| 4 |
* Returns a relative time string for a given date (e.g. "Today" or "2 days ago") |
| 5 |
* |
| 6 |
* @since 4.13.0 updated to use the @wordpress/date functions |
| 7 |
* @since 4.10.0 |
| 8 |
*/ |
| 9 |
export function getRelativeTimeString(date: Date): string { |
| 10 |
const now = getDate(new Date().toISOString()); |
| 11 |
|
| 12 |
return humanTimeDiff(date, now); |
| 13 |
} |
| 14 |
|