blob: 7c2543360353bab574d3f273641335efa8f5cb1f (
plain) (
blame)
1
2
3
4
5
6
7
8
|
import { format, isAfter, subYears } from "date-fns";
export default function BookmarkFormattedCreatedAt(prop: { createdAt: Date }) {
const createdAt = prop.createdAt;
const oneYearAgo = subYears(new Date(), 1);
const formatString = isAfter(createdAt, oneYearAgo) ? "MMM d" : "MMM d, yyyy";
return format(createdAt, formatString);
}
|