aboutsummaryrefslogtreecommitdiff
path: root/examples/starlog/src/components/FormattedDate.astro
blob: 377286d9f421562322d34d9974fd1b3cd1634dc6 (plain) (blame)
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
---
import type { HTMLAttributes } from 'astro/types';

type Props = HTMLAttributes<'time'> & {
	date: Date;
};

const { date, ...attrs } = Astro.props;
---

<time datetime={date.toISOString()} {...attrs}>
	{
		date.toLocaleDateString('en-us', {
			year: 'numeric',
			month: 'short',
			day: 'numeric',
		})
	}
</time>

<style>
	time {
		display: block;
	}
</style>