update dateFormat using date-fns only

This commit is contained in:
somrat sorkar
2024-01-04 14:49:15 +06:00
parent bd1dd7dd02
commit 70d1cc4b88
2 changed files with 20 additions and 19 deletions
+5 -3
View File
@@ -1,10 +1,12 @@
import { formatInTimeZone } from "date-fns-tz";
import { format } from "date-fns";
const dateFormat = (
date: Date | string,
format: string = "dd MMM, yyyy",
pattern: string = "dd MMM, yyyy",
): string => {
return formatInTimeZone(date, "America/New_York", format);
const dateObj = new Date(date);
const output = format(dateObj, pattern);
return output;
};
export default dateFormat;