Files
classroomio/apps/dashboard/src/lib/utils/functions/date.ts
T

15 lines
416 B
TypeScript
Raw Normal View History

import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
dayjs.extend(relativeTime);
export const calDateDiff = (date: string | number | Date): string => {
return dayjs(date).fromNow(true) + ` ago`;
};
2023-10-22 09:47:13 +01:00
export const getGreeting = () => {
const date = new Date();
const hours = date.getHours();
return hours < 12 ? 'Good Morning' : hours < 18 ? 'Good Afternoon' : 'Good Evening';
};