Commit 5c0691d8d6

5c0691d8d65d61f1183419f664df9775d8bcb3f4

parent: 3806d4755b

Unsigned

Alicia Sykes <alicia@omg.lol> · 2024-03-24 13:00 UTC

Adds a timestamp to date util

Layout: unified · split

web/src/utils/dates-n-stuff.ts +9
@@ -6,6 +6,15 @@ export const formatDate = (date: string): string => {
6 }); 6 });
7} 7}
8 8
9export const timestampToDate = (timestamp: number): string => {
10 return new Date(timestamp).toLocaleDateString('en-GB', {
11 day: '2-digit',
12 month: 'short',
13 year: '2-digit'
14 });
15
16}
17
9export const timeAgo = (dateStr: string): string => { 18export const timeAgo = (dateStr: string): string => {
10 const seconds = Math.floor((new Date().getTime() - new Date(dateStr).getTime()) / 1000); 19 const seconds = Math.floor((new Date().getTime() - new Date(dateStr).getTime()) / 1000);
11 const intervals = { 20 const intervals = {