-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharticle-dates.tsx
More file actions
35 lines (32 loc) · 859 Bytes
/
Copy patharticle-dates.tsx
File metadata and controls
35 lines (32 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
interface ArticleDatesProps {
createDate: number;
updateDate: number | null;
}
const formatDate = (timestamp: number) =>
new Date(timestamp).toLocaleDateString('en-us', {
dateStyle: 'medium',
timeZone: 'UTC',
});
export function ArticleDates(props: ArticleDatesProps) {
const { createDate, updateDate } = props;
return (
<div className="text-xs text-gray-700 dark:text-gray-300">
<p>
Published on{' '}
<time dateTime={new Date(createDate).toISOString()}>
{formatDate(createDate)}
</time>
</p>
{updateDate && (
<p>
Last updated on{' '}
<strong className="font-medium">
<time dateTime={new Date(updateDate).toISOString()}>
{formatDate(updateDate)}
</time>
</strong>
</p>
)}
</div>
);
}