Skip to content

Commit a180ee4

Browse files
committed
Add date formatting helper
1 parent 59869ec commit a180ee4

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/utils/date.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function formatDate(date: number | Date): string {
2+
return new Intl.DateTimeFormat('en-US', { dateStyle: 'medium' }).format(date);
3+
}
4+
5+
export function formatTime(date: number | Date): string {
6+
return new Intl.DateTimeFormat('en-US', { timeStyle: 'short' }).format(date);
7+
}

src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './colors';
2+
export * from './date';
23
export * from './emoji';
34
export * from './list';
45
export * from './math';

0 commit comments

Comments
 (0)