Adds a timestamp to date util

This commit is contained in:
Alicia Sykes 2024-03-24 13:00:42 +00:00
parent 3806d4755b
commit 5c0691d8d6

View file

@ -6,6 +6,15 @@ export const formatDate = (date: string): string => {
});
}
export const timestampToDate = (timestamp: number): string => {
return new Date(timestamp).toLocaleDateString('en-GB', {
day: '2-digit',
month: 'short',
year: '2-digit'
});
}
export const timeAgo = (dateStr: string): string => {
const seconds = Math.floor((new Date().getTime() - new Date(dateStr).getTime()) / 1000);
const intervals = {