update date time short format

This commit is contained in:
Abhinav 2022-11-25 13:42:55 +05:30
parent 6651a9c022
commit e7645dc090

View file

@ -35,6 +35,18 @@ export function formatDate(date: number | Date) {
.join(' '); .join(' ');
} }
export function formatDateTimeShort(date: number | Date) {
const dateTimeFormat = new Intl.DateTimeFormat('en-US', {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
});
return dateTimeFormat.format(date);
}
export function formatTime(date: number | Date) { export function formatTime(date: number | Date) {
const timeFormat = new Intl.DateTimeFormat('en-IN', { const timeFormat = new Intl.DateTimeFormat('en-IN', {
timeStyle: 'short', timeStyle: 'short',
@ -52,10 +64,6 @@ export function formatDateTime(dateTime: number | Date): string {
return [formatDate(dateTime), constants.AT, formatTime(dateTime)].join(' '); return [formatDate(dateTime), constants.AT, formatTime(dateTime)].join(' ');
} }
export function formatDateTimeShort(date: number | Date) {
return [formatDateFull(date), formatTime(date)].join(' ');
}
export function formatDateRelative(date: number) { export function formatDateRelative(date: number) {
const units = { const units = {
year: 24 * 60 * 60 * 1000 * 365, year: 24 * 60 * 60 * 1000 * 365,