Files
no-copy-frontend/src/app/lib/formatDate.ts
T

25 lines
681 B
TypeScript
Raw Normal View History

2026-02-21 15:07:37 +07:00
// Форматирование даты из timestamp
export const formatDate = (timestamp: number | string) => {
2026-02-25 12:53:18 +07:00
if (!timestamp) {
return '---'
}
2026-02-21 15:07:37 +07:00
const date = new Date(timestamp);
const day = date.getDate().toString().padStart(2, '0');
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const year = date.getFullYear();
return `${day}.${month}.${year}`;
};
export const formatDateTime = (timestamp: number | string) => {
2026-02-25 12:53:18 +07:00
if (!timestamp) {
return '---'
}
2026-02-21 15:07:37 +07:00
const date = new Date(timestamp);
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
return `${hours}:${minutes}`;
};