📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Added formatTime helper to format just amount of minutes, hours, etc.
Blue Mouse48911c03425a
diff --git a/app/utils/date.ts b/app/utils/date.tsindex 205f5544a..ca4e81e2e 100644--- a/app/utils/date.ts+++ b/app/utils/date.ts@@ -27,6 +27,20 @@ const formatTimeAgo = (date, language?: string) => {}}+export const formatTime = (+ value: number,+ unit: Intl.RelativeTimeFormatUnit,+ language = 'en',+ style: Intl.RelativeTimeFormatStyle = 'short',+) => {+ const rtf = new Intl.RelativeTimeFormat(language, { numeric: 'always', style })++ const formatted = rtf.format(value, unit)++ // Remove the 'in' prefix (and it's alternatives in other languages)+ return formatted.replace(/^.*?(\d+)/, '$1').trim()+}+export const getRelativeDateIfPossible = (date: string, language?: string) => {if (!Intl?.RelativeTimeFormat) {return new Date(date).toLocaleDateString(language, {