2023-10-18 21:43:46 +05:30
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
|
|
|
|
|
|
|
|
dayjs.extend(customParseFormat);
|
|
|
|
|
|
2023-01-24 18:53:04 +05:30
|
|
|
export function toUTCEpoch(time: number): number {
|
2021-02-21 06:23:56 +05:30
|
|
|
const x = new Date();
|
|
|
|
|
return time + x.getTimezoneOffset() * 60 * 1000;
|
2023-01-24 18:53:04 +05:30
|
|
|
}
|
2023-10-18 21:43:46 +05:30
|
|
|
|
|
|
|
|
export const getFormattedDate = (epochTimestamp: number): string => {
|
|
|
|
|
// Convert epoch timestamp to a date
|
|
|
|
|
const date = dayjs.unix(epochTimestamp);
|
|
|
|
|
|
|
|
|
|
// Format the date as "18 Nov 2013"
|
|
|
|
|
return date.format('DD MMM YYYY');
|
|
|
|
|
};
|