Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

show year if date is from previous years

Steven Tey5412f4beff37
diff --git a/lib/utils.ts b/lib/utils.ts
index b0833b1c7f..2f9d706cf7 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -149,6 +149,10 @@ export const timeAgo = (timestamp?: Date): string => {
return new Date(timestamp).toLocaleDateString("en-US", {
month: "short",
day: "numeric",
+ year:
+ new Date(timestamp).getFullYear() !== new Date().getFullYear()
+ ? "numeric"
+ : undefined,
});
}
return ms(diff);